I am using the FT Calendar Plugin. My question is how can I order posts of a custom post type by the event calendar date?

So for instance I have a CPT named "Events" and for each event post a calendar date is added. Problem is that the page that lists the event posts doesn't order the posts by event calendar date, but the standard wordpress ordering. Is there a way to order them in my query instead by the FT Calendar event date?

The data for the event dates are stored in their own table "rfw_ftcalendar_events".

id | calendar_id | post_parent | start_datetime      | end_datetime

1  | 2           | 210         | 2013-04-05 15:00:00 | 2013-04-05 16:00:00

1 Answer 1


My guess is that the calendar date is some sort of meta field for the custom post type. I'd find that out and add that as a variable for my query.

You might be able to use something like this

<?php $loop = new WP_Query( array( 'post_type' => 'events', 'meta_key'=>'start_datetime',  'orderby' => 'meta_value', 'order' => ASC) ); while ( $loop->have_posts() ) : $loop->the_post(); ?>
  • 1
    But of course you wouldn't use query_posts, right?
    – vancoder
    Commented Apr 30, 2013 at 17:46
  • I just updated my question. The data is actually stored in a separate table "rfw_ftcalendar_events". Commented Apr 30, 2013 at 19:07
  • @vancoder wouldn't it though? When he's trying to display all posts of the custom post type, he'd have to query it, right? At which point he could add the query arguments and orderby=meta_value&meta_key=start_datetime ...then again, I could be wrong or misunderstanding what he's looking for?
    – NW Tech
    Commented Apr 30, 2013 at 19:28
  • @NWTech Your concept is fine, but query_posts is best avoided. See here for why. That said, the OP has now specified a custom table, so this is all academic.
    – vancoder
    Commented Apr 30, 2013 at 20:23
  • @vancoder thanks for enlightening me on my deprecated example.
    – NW Tech
    Commented Apr 30, 2013 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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