Display order of category names
-
Hi everybody,
on our book review blog, every category is the name of a a books author, e. g. “The old man and the sea” is filed under “Ernest Hemmingway”.
Is there any way to alter the output on the archives pages since I would like the categories to be sorted by the surname (e. g. “Hemmingway, Ernest”). Since the author shall be shown correctly with first and surname on the single pages, I somehow need to versions of every category.
This is the code I’m using for the category index:
<?php $taxonomy = 'category'; $param_type = 'category__in'; $term_args=array( 'orderby' => 'name', 'order' => 'ASC' ); $terms = get_terms($taxonomy,$term_args); if ($terms) { foreach( $terms as $term ) { $args=array( "$param_type" => array($term->term_id), 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => -1, 'caller_get_posts'=> 1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { ?> <h2 style="margin-bottom: 0px;"><?php echo $term->name;?></h2> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <a>" rel="bookmark"><?php the_title(); ?></a> <?php endwhile; ?> <?php } } } wp_reset_query(); // Restore global post data stomped by the_post(). ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Display order of category names’ is closed to new replies.