Forums

Post Order (6 posts)

  1. BennoH
    Member
    Posted 6 months ago #

    Hello. I would like to change the order of the posts on my homepage. I have had a look at the advice on the following link;

    http://codex.wordpress.org/Function_Reference/query_posts

    Being a total novice, I do not understand this and it may aswell be martian! Could somebody please talk me through how to change the order of the posts on my homepage. Many thanks.

  2. duck__boy
    Member
    Posted 6 months ago #

    $args = array(
        'orderby' => 'name', // Can be 'id', 'name', 'date', etc...
        'order' => ASC // Can be ASC or DESC
    );
    query_posts($args);

    If you are already parsing $args to query_posts() then ensure that you add the above options to those $args, as opposed to redeclaring $args and overwriting them.

  3. BennoH
    Member
    Posted 6 months ago #

    Thanks for the help duck_boy, unfortunately I do not understand this. I am a total novice and know next to nothing about code. Could you please elaborate in layman's terms?

  4. duck__boy
    Member
    Posted 6 months ago #

    From your root folder navigate to '/wp-content/themes/{whatever theme}/' and find a file called 'index.php'. This is where WP gets the posts that it displays.

    Do a search and look for 'query_posts' - if you do not find it, copy the code above and place it just before The Loop, which will be identifed by one of the following -

    if(have_posts) : while(have_posts) : the_post() ....
    template_part('loop', 'index');

    Make sure you use a proper eidtor (I use Total Edit), not MS Word, as that will mess the file up. and make sure that the code is inside PHP tags (<?php {Your code} ?>).

  5. BennoH
    Member
    Posted 6 months ago #

    Brilliant. That is exactly what I was after... Many thanks!

  6. duck__boy
    Member
    Posted 6 months ago #

    No probelem, hope it helps.

Reply

You must log in to post.

About this Topic