我有一个自定义搜索页面,可通过该页面选择:
One or ALL categories
One or ALL tags
One or ALL authors
A search string or no search string
在结果页面上,当我选择了值时,wp\\u查询就会工作。但我如何指示将某个参数设置为ALL?例如,如何设置“搜索所有类别”?也许我需要打破我的参数,只有当我得到值时才添加到它们?但我该怎么做呢?
谢谢
编辑我修改了wp查询,现在如下所示。一切都很好,但我没有分页!
$args = array( \'order\' => \'DESC\', \'orderby\' => \'date\', \'posts_per_page\'=> 10 );
if ( \'0\' != $category ) { $args[\'cat\'] = $category; }
if ( \'0\' != $tag ) { $args[\'tag\'] = $tag; }
if ( \'0\' != $author ) { $args[\'author\'] = $author; }
if ( \'\' != $search ) { $args[\'s\'] = $search; }
$the_query = new WP_Query( $args );
while ($the_query-> have_posts()) : $the_query->the_post();
....
endwhile;
wp_pagenavi( array( \'query\' => $the_query ) );