Wordpress: Sort Order by Custom Field for specific Category


/ Published in: PHP
Save to your folder(s)

Put this before the loop in archive.php to have posts in the archive for category '26' sorted by custom field 'date'.
Assign sortable values like '090501' or '2009-05-01' to those fields when editing posts and your Upcoming Events will be sorted by the future date at which they will take place.


Copy this code and paste it in your HTML
  1. <?php if (is_category('26')) { $posts = query_posts($query_string. '&orderby=meta_value&meta_key=date&order=DESC' ); } ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.