I´d like to display all car manufacturer in order by title (e.g. “Merecedes”) and order from lowest to highest values (e.g. “A-Class”) “ASC”, too. It should looks like a glossary.
Page: Cars
A
…
BMW:
1er
2er
3er
…
Mercedes:
A-Class
B-Class
C-Class
…
Z
This is my custom-port-type-cars.php
<h2>Mercedes</h2>
<?php $args = array( 'post_type' => 'cars', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC',
// ============================= Mercedes ==============================
'tax_query' => array(
array(
'taxonomy' => 'manufacturer',
'field' => 'slug',
'terms' => array('mercedes')
)
)
);
// ============================= OUTPUT ==============================
$loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post();
the_title('<h3>', '</h3>');
the_content();
endwhile; ?>
<h2>BMW</h2>
<?php $args = array( 'post_type' => 'cars', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC',
// ============================= BMW ==============================
'tax_query' => array(
array(
'taxonomy' => 'manufacturer',
'field' => 'slug',
'terms' => array('bmw')
)
)
);
// ============================= OUTPUT ==============================
$loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post();
the_title('<h3>', '</h3>');
the_content();
endwhile; ?>
This doesn´t work for me. I can´t order title an terms at the same time.
Thanks for your help
Ogni
1 comment