WordPress.org

Ready to get started?Download WordPress

Forums

Order categories by description (1 post)

  1. wutzelmutz
    Member
    Posted 1 year ago #

    Hi everyone,

    I'm using the following code to list all categories by slug with their certain posts beneath:

    <?php
    	$taxonomy = 'category';
    	$param_type = 'category__in';
    	$term_args=array(
    	'orderby' => 'slug',
    	'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().
    	?>

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

    How can I alter this code in order so sort by the categories' description and replace the category name by its description?
    I have been searching for a solution for quite a while now and I hope this does work somehow. Can you please help me?

    Thanks in advance.

Topic Closed

This topic has been closed to new replies.

About this Topic