Membership is FREE – with unlimited access to all features, tools, and discussions. Premium accounts get benefits like banner ads and newsletter exposure. ✅ Signature links are now free for all. 🚫 No AI-generated (LLM) posts allowed. Share your own thoughts and experience — accounts may be terminated for violations.

Order by Post ID

Status
Not open for further replies.
Joined
Aug 25, 2007
Posts
2,235
Reaction score
41
Anyone know of a plugin that can automatically force order all posts within a category by post ID - or even all posts by post id.

Had a good look, maybe I'm missing something :confused:

ta.
 
Thanks, but that's more of an admin tool for reordering the current posts within a site.

I'm trying to display all recent posts based on the exact time they are created or the unique post_id - (automatically).

Say 500 people make one post each under multiple categories, when one of those categories is selected I want to force the display of the posts by the date they were created or post id ASC, I'm really surprised there not a way to do in WP without getting me hands dirty with some SQL :rolleyes:


 
Use the posts_orderby hook in your themes functions.php file and filter for a category archive to tweak the main query...

Code:
function tweak_category_order( $orderby ) {

    if ( ! is_admin() && is_category( XX ) ) {
         return "ID ASC"; //or ID DESC
    }
     //not cat
     return $orderby;
}
add_filter('posts_orderby', 'tweak_category_order' );

Will work for front-end but leave admin posts display as is.

Change the XX to either the id, slug or name as show here: http://codex.wordpress.org/Conditional_Tags

query_posts is the spawn of satan! It throws away the default query and uses a new one so any url parsing is lost. Destroys any functionality that many plugins with additional url parameters require. Just look through a lot of shitty free themes to see how much it is abused! :)
 
Last edited:
thx for your help all, will try in morning when fresh.. after me cup of gold blend :???:

this is just rough experiment t-v, but is is bit tricky ordering 20,000 tv listing posts on a rolling basis.



Use the posts_orderby hook in your themes functions.php file and filter for a category archive to tweak the main query...

Code:
function tweak_category_order( $orderby ) {

    if ( ! is_admin() && is_category( XX ) ) {
         return "ID ASC"; //or ID DESC
    }
     //not cat
     return $orderby;
}
add_filter('posts_orderby', 'tweak_category_order' );

Will work for front-end but leave admin posts display as is.

Change the XX to either the id, slug or name as show here: http://codex.wordpress.org/Conditional_Tags

query_posts is the spawn of satan! It throws away the default query and uses a new one so any url parsing is lost. Destroys any functionality that many plugins with additional url parameters require. Just look through a lot of shitty free themes to see how much it is abused! :)
 
Status
Not open for further replies.

Rule #1: Be Respectful

Do not insult any other member. Be polite and do business. Thank you!

Premium Members

New Threads

Domain Forum Friends

Lastest Listings

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Siusaidh AcornBot:
    Siusaidh has left the room.
      Siusaidh AcornBot: Siusaidh has left the room.
      Top Bottom