Pages

Monday, January 23, 2012

Wordpress: Ordering posts by Meta value

In the query_posts functions parameter, we need to add this:

meta_key=<KEY_NAME>&orderby=meta_value_number&order=DESC

Replace <KEY_NAME> the with your meta key name For example:


<?php query_posts( 'meta_key=<KEY_NAME>&orderby=meta_value_number&order=ASC' ); ?>


Order Could be ASC - Ascending or DESC - descending 

No comments :

Post a Comment