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(
                        'post_type' => "event",
                        'posts_per_page' => 40,
                        'meta_key'    => 'wpcf-start-date',  // load up the event_date meta
                        'orderby'     => 'meta_value',
                        'order'       => 'asc',


Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen.

WordPress.com logo

Je reageert onder je WordPress.com account. Log uit /  Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit /  Bijwerken )

Verbinden met %s