Order Custom Post Type by custom Field with Types Plugin in WordPress

First you need to choose which post type you want to list and to choose a custom field to filter by you use the “meta_key” key in the array. The key starts with “wpcf-” and afterwards the name of the custom field you want to use.

$posts = query_posts(
   array(
                        'post_type' => "event",
                        'posts_per_page' => 40,
                        'meta_key'    => 'wpcf-start-date',  // load up the event_date meta
                        'orderby'     => 'meta_value',
                        'order'       => 'asc',
     )
);

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s