I need to get custom post type data for usage with Timber and Twig, it's working fine using the standard WP_Query, such as:
// Get the testimonials custom post type posts
$args = array(
'post_type' => 'testimonial',
'post_status' => 'publish',
'perm' => 'readable',
'nopaging' => true
);
$context['testimonials'] = new WP_Query( $args );
// Restore the global $post to the current post in the main query
wp_reset_postdata();
However this obviously doesn't get ACF fields.
Was going to do the below as indicated in the Timber docs:
// Get the testimonials custom post type posts
$args = array(
'post_type' => 'testimonial',
'post_status' => 'publish',
'perm' => 'readable',
'nopaging' => true
);
$context['testimonials'] = Timber::get_posts( $args );
However, it seems that get_posts is getting deprecated in 2.0.
It seems like the best way to do it would be by using Timber's PostQuery, but because of lacking documentation I am unsure if it is more or less an encapsulation of WP_query and I can simply do something like:
// Get the testimonials custom post type posts
$args = array(
'post_type' => 'testimonial',
'post_status' => 'publish',
'perm' => 'readable',
'nopaging' => true
);
$context['testimonials'] = new PostQuery(array('query' => $args));
Am I on the right track here or what is the correct way?