T
T
tester2018-08-04 10:15:39
WordPress
tester, 2018-08-04 10:15:39

How to sort custom posts by taxonomy?

Hello! There is this code:

<?php
                if ($attachments) {
                    foreach ( $attachments as $attachment ) { setup_postdata($attachments);?>
                        <div class="col-lg-4 col-sm-6 col-12 project cat1">
                            <!-- <div class="project-wrap">
                                <?php echo get_the_post_thumbnail( $attachment->ID); ?>
                                <div class="project-content">
                                    <a href="<?php echo get_the_post_thumbnail_url( $attachment->ID); ?>" class="popup"><i class="fa fa-search"></i></a>
                                    <h3>Architecture Building</h3>
                                </div>
                            </div> -->
                            <pre><?php print_r($attachment); ?></pre>
                        </div>
            <?php } } wp_reset_postdata(); ?>

It outputs all categories, but how can I sort them?
category_name etc don't work.
5b62e7d4058f4046832191.png
function archirio_custompost_type_projects() {
  $labels = array(
    'name'              => 'Home Latest Projects',
    'singular_name'     => 'Home Latest Projects',
  );

  $args = array(
    'labels'             => $labels,
    'public'             => true,
    'publicly_queryable' => true,
    'show_ui'            => true,
    'show_in_menu'       => true,
    'query_var'          => true,
    'rewrite'            => array( 'slug' => 'Home Latest Projects' ),
    'capability_type'    => 'post',
    'has_archive'        => true,
    'hierarchical'       => false,
    'menu_position'      => null,
    'supports'           => array( 'title', 'editor', 'thumbnail' ),
  );

  register_post_type( 'home_latest_projects', $args );
  flush_rewrite_rules();
}

add_action( 'init', 'archirio_custompost_type_projects' );

function archirio_custom_taxonomy() {
  $args = array(
    'label'        => __( 'Rubric', 'textdomain' ),
    'public'       => true,
    'rewrite'      => false,
    'hierarchical' => true
  );

  register_taxonomy( 'Rubric', 'home_latest_projects', $args );
}

add_action( 'init', 'archirio_custom_taxonomy', 0 );

Link to layout - tokmaganbet.ru/sites/archirio

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question