admin管理员组文章数量:1278854
I'm trying to enable users to select individual posts by custom post type using a new WP_Query
$posts = new WP_Query( array(
'post__in' => selected_posts(),
'post_type' => $post_types,
) );
And using a custom function based on user selection but its not working
function selected_posts() {
$post_in = get_post_meta( get_the_ID(), 'post_in', true );
$page_in = get_post_meta( get_the_ID(), 'page_in', true );
$custom_post_type_in = get_post_meta( get_the_ID(), 'custom_post_type_in', true );
if ( $custom_post_type_in == 'true' ) :
$show = $custom_post_type_in;
elseif ( $page_in == 'true' ) :
$show = $page_in;
else :
$show = $post_in;
endif;
}
The value for post__in
parameter should be shown when a specific post type is selected including post, page and cpt and only posts selected for that post type should be shown using the 'post__in'
parameter.
本文标签: wp queryCreate if else for post types in WPQuery 39postin39 values
版权声明:本文标题:wp query - Create if else for post types in WP_Query 'post__in' values 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741239677a2363724.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论