Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom field named: eventdate The posts are all in the standard post type. I want to order by this field ascending. I have tried over 15 different solutions but no joy . Every post simply gets turned into a list of all posts.

I have tried all solutions both before and after the following.

if(have_posts()){
 while (have_posts()) : the_post();

Please help, I have been trying to sort this for at least 14 hours.

share|improve this question
    
do you want to show all posts which has only meta_key = eventdate in a specific category. –  balamurugan Jan 9 '13 at 5:51
add comment

1 Answer 1

you can use query_posts to sort the post by you custom field, Add this before you loop

query_posts( $query_string . 'meta_key=eventdate&order=ASC&orderby=meta_value');
share|improve this answer
    
thanks for looking but that just seems to lists all posts in all categories and not the order within categories. Any other idea please? –  Adam Feb 25 '12 at 12:14
    
this code assumes you are in a category archive if not then just add &cat=cat_ID and change cat_ID with the actual category id –  Bainternet Feb 25 '12 at 13:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.