Support » Plugin: Sort Query Posts » Sort Query Posts – How to use this plugin?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Also wondering how to use this one.

    Need to sort posts on front page by date.

    Help please?

    Plugin Author Tubal

    (@tubal)

    Hi,

    First of all, to use this plugin you have to be able to edit your theme files, there’s no admin screen.

    Its use is extremely simple, you have to call the function sort_query_posts_by(string $order_by [, string $order]) in the theme file (home.php, index.php, templates, page.php etc…) where you want the posts sorted. One line…all done.

    For example, to sort posts by title in descending order in your homepage you have to include this line in your theme file (usually home.php) before the loop:

    <?php 
    
    // Sort posts
    sort_query_posts_by('title', 'desc'); 
    
    // Display posts (in the order specified above)
    while ( have_posts() ): the_post();
        the_title();
        echo '<br>';
        the_excerpt();
    endwhile;
    
    ?>

    Hope this helps!!

    Works fine for me! Thanks! You should include select with options of sorting posts.
    (simple add to category.php and index.php -> <?php sort_select(‘title-desc’,’title-asc’,’id’,’date’);?> ) 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sort Query Posts – How to use this plugin?’ is closed to new replies.