0

I'm displaying my post category by the following:

<?php   
foreach (get_categories() as $cat) :?>

<div class="post animation-element bounce-up cf" <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<div class="row subject ">
<div class="col-md-12 col-sm-12 col-xs-12 col-lg-12 ">
<a href="<?php echo get_category_link($cat->term_id); ?>">
<img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" />  </a> 
</div>
</div>
</div>

My category display by title ascendant this way, but I am looking to display them by title descendant.

1 Answer 1

0

If only you could use get_categories() reference in the Codex, you could see that this function supports arguments.

<?php
$categories = get_categories( array(
    'orderby' => 'name', // default value, can omit it
    'order'   => 'DESC'
));

foreach($categories as $cat) {
    // your code goes here
}
2
  • Hi Max, Thanks, I'e try your code but it still display in ASC unfortunately :( any idea :( ? Really appreciate your time
    – tibewww
    Commented Jul 6, 2017 at 10:14
  • That's impossible. Have you emptied all caches?
    – Max Yudin
    Commented Jul 6, 2017 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.