我正在使用两个自定义post_types,我在搜索页面中显示它们。 我需要根据帖子类型对帖子进行排序。
like if(custom_post_type1)
{
print all posts under custom_post_type1;
}elseif(custom_post_type2)
{
print all posts under custom_post_type2;
}
我可以看到有query_post,我不确定参数,特别是我需要帖子类型1在这些帖子之后的第一个和另一个。 我需要在搜索结果页面中排序。
答案 0 :(得分:0)
直接来自wordpress docs。
<?php
$args = array( 'post_type' => 'your_custom_post_type', 'posts_per_page' => -1, 'post_status' => 'any', 'post_parent' => null );
$custom_posts = get_posts( $args );
?>