WordPress.org

Ready to get started?Download WordPress

Forums

Sort Query Posts
[resolved] Sort Query Posts - How to use this plugin? (4 posts)

  1. mei460
    Member
    Posted 2 years ago #

    Hi,

    Just download this plugin but am puzzle on how to use it.

    Please could anyone share with me how to implement it to my post order so that it can be arrange by title?

    Thanks,
    May

    http://wordpress.org/extend/plugins/sort-query-posts/

  2. SeanDW
    Member
    Posted 2 years ago #

    Also wondering how to use this one.

    Need to sort posts on front page by date.

    Help please?

  3. Tubal
    Member
    Plugin Author

    Posted 2 years ago #

    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!!

  4. maxbmx
    Member
    Posted 2 years ago #

    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');?> ) :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic