Web Designing, Web Development, Website Design, Website Development, SEO

0091 98233 72069

COGS: CUSTOMISED, OPTIMISED, GENERALISED WEB DESIGN & WEB DEVELOPMENT SOLUTIONS

wordpress sort posts by custom field numeric value

there is no default option in wordpress to set up sort order of post manually while adding post. Other options are sorting by title or date using query_post() function.  To set up custom sort order we can do this using custom field. Use following code

query_posts(orderby=meta_value&meta_key=sort_order&order=ASC’);

REMEMBER: if you use this function then you have to assign sort_order custom field to each post. Otherwise posts which do not have sort_order custom field will not be displayed.