• This is the code for my asides. Please help me figure out how to change this code to list posts in descending order. I worked on it a bit myself but I can’t figure it out.

    <?php if ($posts) : foreach ($posts as $post) : the_post() ?>
    <?php if (in_category(109)) { ?>
    
    <div class="asides_sidebar">
    
                        <h3 style="padding:0 0 0px !important;margin: 0 0 5px 105px !important;text-indent: -105px; margin-top: 0; margin-bottom: 0;><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
    
    </div>
    <?php } ?>
    <?php endforeach; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Try changing.

    <?php if ($posts) :

    to.

    <?php if ($posts) :
    ksort($posts); // Sort the array by key (shouldn't be required, but just incase)
    array_reverse($posts,true); // Reverse the array, preserving keys

    Or you might need to do it like this..

    <?php if ($posts) :
    $posts = ksort($posts); // Sort the array by key (shouldn't be required, but just incase)
    $posts = array_reverse($posts,true); // Reverse the array, preserving keys

    Thread Starter bradygo

    (@bradygo)

    Thanks for the reply, but I couldnt get this work either. Frustrating….

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Descending Order?’ is closed to new replies.