我需要获取用于Timber和Twig的自定义帖子类型数据,使用标准1
可以正常工作,例如:
WP_Query
但是,这显然没有ACF字段。
要按照Timber文档中的说明进行以下操作:
// 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();
但是,看来// Get the testimonials custom post type posts
$args = array(
'post_type' => 'testimonial','nopaging' => true
);
$context['testimonials'] = Timber::get_posts( $args );
正在获得deprecated in 2.0。
似乎最好的方法是使用Timber的get_posts
,但是由于缺乏文档,我不确定它是或多或少是PostQuery
的封装,我可以简单地做像这样:
WP_query
我在正确的轨道上还是正确的方法?