【发布时间】:2016-06-03 12:55:19
【问题描述】:
我有一个search.php文件,显示用户搜索的搜索结果,使用如下代码:
<?php
$s=get_search_query();
$args = array('s' =>$s);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) { ?>
<?php while ( $the_query->have_posts() ) {
$the_query->the_post();
?>
<h1><?php the_title(); ?></h1>
<?php }
}else{ ?>
<h1>No search results found</h1>
<?php }
?>
有没有一种方法可以过滤不同(自定义)帖子类型之间的结果?
像这样:
- item1 (post)
- item2 (custom post type named 'clients')
- item3 (custom post type named 'clients')
- item4 (custom post type named 'occasions')
- item5 (post)
【问题讨论】:
-
`
()
-
效果很好!你能把这个作为答案发布吗?所以我可以批准它