我已经搜索了数千篇相关帖子,似乎无法在这个循环中使用分页。
只要我点击下一页,我就会得到一个404
//get the search term
if (!empty($_GET["s"])){
$s = $_GET["s"];
//the search form will have an input value of "Search..." if nothing has been selected. We need to clear
if ($s=="Search..."){
$s=\'\';
}
}
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
$limit = 10;
$args = array(
//the user inputed search term
\'s\' => $s,
\'post_type\' => \'schools\',
\'posts_per_page\' => 5,
\'paged\' => $paged,
//we use tax_query here to query the schools custom taxonomy.
\'tax_query\' => array(
\'relation\' => \'AND\',
array(
//name of school categories (custom taxonomy)
\'taxonomy\' => \'school_category\',
//we are going to search by matching category ids
\'field\' => \'id\',
//the array we created that contains all the category ids to be searched
\'terms\' => $category_and,
//we want to make sure only posts in all of the categories selected are shown.
\'operator\' => \'AND\'
),
array(
//name of school categories (custom taxonomy)
\'taxonomy\' => \'school_moi\',
//we are going to search by matching category ids
\'field\' => \'id\',
//the array we created that contains all the category ids to be searched
\'terms\' => $category_MOI,
//we want to make sure only posts in all of the categories selected are shown.
\'operator\' => \'AND\'
),
array(
//name of school categories (custom taxonomy)
\'taxonomy\' => \'school_curriculum\',
//we are going to search by matching category ids
\'field\' => \'id\',
//the array we created that contains all the category ids to be searched
\'terms\' => $category_cur,
//we want to make sure only posts in all of the categories selected are shown.
\'operator\' => \'AND\'
)
)
);
//The new query with our arguements
$wp_query = new WP_Query( $args );
woo_loop_before();
if ($wp_query->have_posts()) { $count = 0;
$title_before = \'<h1 class="archive_header">\';
$title_after = \'</h1>\';
//echo $title_before . sprintf( __( \'Search results for "%s"\', \'woothemes\' ), get_search_query() ) . $title_after;
?>
<div class="fix"></div>
<?php
//Make sure the search results take into account the categories chosen on the seach bar
while ($wp_query->have_posts()) {$wp_query->the_post(); $count++;
if (get_option(\'woo_woo_tumblog_switch\') == \'true\') { $is_tumblog = woo_tumblog_test(); } else { $is_tumblog = false; }
woo_get_template_part( \'content\', \'search\' );
} // End WHILE Loop
next_posts_link(\'« Next\');
previous_posts_link(\'Previous »\');
//wp_reset_postdata();
} else {
get_template_part( \'content\', \'noposts\' );
} // End IF Statement
woo_loop_after();
我有
blog pages show at most option 设置为1。
非常感谢您的帮助!
谢谢