WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Sorting posts, per category, by priority (6 posts)

  1. Daffydd57
    Member
    Posted 4 years ago #

    Hi all,

    Would like to use the WordPress admin as a news updater - pushing the stories to my website. I would like to be able- throught custom field? - to give a post a priority number so that the posts will fall onto the homepage in the order we want them to.

    Can this be done? I would appreciate any info on this. I know nothing about coding php or MySQL so details would be great! :)

    Thanks so much!
    Daf

  2. Daffydd57
    Member
    Posted 4 years ago #

    Okay - I'm making some headway here.

    I'm thinking that I can use the custom fields - set to "Priority" and set the value (1 through 9) per post.

    Then - and this is where I get a bit lost - I can use the

    query_posts('meta_key=priority&meta_value=1');

    or use the meta_compare - I'm not sure...

    I could then, if I am not mistaken, push all the posts with the "1" value to the homepage. That is part of the solution.

    What I want to do, and don't know how to modify the query_posts statement - is display the posts ranked by meta_key value. So that all the "1" posts are first, then followed by "2", etc...

    So little help with that code would be greatly appreciated! :)

    Thanks!

  3. xdesi
    Member
    Posted 4 years ago #

    Does:

    query_posts('meta_key=priority&orderby=meta_value&order=ASC');

    Work?

  4. Daffydd57
    Member
    Posted 4 years ago #

    xdesi - it does appear to be doing what I want!!! Thanks so much!

  5. xdesi
    Member
    Posted 4 years ago #

    Nice one :)

  6. Daffydd57
    Member
    Posted 4 years ago #

    Okay - let's try to take this a step further if possible. The above system is working perfectly - but I would like for each new post to have a default meta_key - meta_value of 5 for the priority custom field.

    So that when bringing up the new post dialog the custom field is already set to "priority" and the value is set to "5"

    Asking too much? :)

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic