Results 1 to 6 of 6

Thread: Changing Front Page from 'Most Recent'

  1. #1
    Thread Starter
    Senior Member jakesterz's Avatar
    Join Date
    Aug 2009
    Posts
    194
    Thanks
    0
    Thanked 1 Time in 1 Post

    Changing Front Page from 'Most Recent'

    How can I change the listings so the default is to show them sorted another way? For instance for the front page to show them sorted by price by default? So the lowest priced will always be on the front page rather than the most recent?

  2. #2
    Senior Member
    Not a Verified Customer
    chanders's Avatar
    Join Date
    Jul 2009
    Posts
    120
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing Front Page from 'Most Recent'

    Well first of all, the price field is not numeric so sorting by price would be useless if someone include text in the price field such as

    $300 or nearest offer

    If this is not a problem then sorting by another field would be very simple.

  3. #3
    Thread Starter
    Senior Member jakesterz's Avatar
    Join Date
    Aug 2009
    Posts
    194
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Changing Front Page from 'Most Recent'

    I've actually replaced "price" with a numeric string. If it's simple, how?

  4. #4
    Junior Member
    Not a Verified Customer
    Harris-Ort's Avatar
    Join Date
    Aug 2009
    Location
    New Jersey, US
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing Front Page from 'Most Recent'

    One thing Wordpress does not provide it is: order by custom field.
    That means you would need a custom query post in order to sort the posts by custom field, in this case "price".

    Would be something like this:
    Code:
    <?php
    $querystr = "
        SELECT wposts.* 
        FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
        WHERE wposts.ID = wpostmeta.post_id 
        AND wpostmeta.meta_key = 'price' 
        AND wposts.post_type = 'page' 
        ORDER BY wpostmeta.meta_value ASC
        ";  ?>
    IMO, I don't think it is a good idea. Creating an worst case scenario here. " 2 months ago you had 50 items costing between $10 and $50. This week you had 30 users adding items costing more than $100. What happens to your front page? it will still be showing all the old items while the new ones will never get to the homepage."
    Some users may not like that and some others may set the price in the custom field as $0 and the real price in the description just to appear on the front page.
    Just my opinion though.

  5. #5
    Thread Starter
    Senior Member jakesterz's Avatar
    Join Date
    Aug 2009
    Posts
    194
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Changing Front Page from 'Most Recent'

    I've actually replaced "price" with something else. It's just still using the "Price" column on the front page.

    Where would that code go?

  6. #6
    Junior Member
    Not a Verified Customer
    Harris-Ort's Avatar
    Join Date
    Aug 2009
    Location
    New Jersey, US
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing Front Page from 'Most Recent'

    I've actually replaced "price" with something else. It's just still using the "Price" column on the front page.
    I see!

    That code would go on the index.php and on top of the loop. However the Classipress uses a very complex loop with lots of if and else statements. That means the loop will have to be changed as well.

    A very good resource can be found here: http://codex.wordpress.org/Displaying_P ... lect_Query

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)