Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.

Order by Post ID

Status
Not open for further replies.
Joined
Aug 25, 2007
Posts
2,239
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.

The Rule #1

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

Featured Services

Auctions Ending - Flip.uk

Sedo - it.com Premiums

IT.com

Premium Members

AucDom
UKBackorder
Register for the auction

Latest Comments

Acorn Domains Merch
MariaBuy Marketplace

Domain Forum Friends

Other domain-related communities we can recommend.

Our Mods' Businesses

Perfect
Service
Laskos
*the exceptional businesses of our esteemed moderators
Top Bottom