我有一个使用自定义查询按国家/地区搜索帖子的网站。
搜索结果很好,但底部的分页反映了网站中的帖子总数,而不是搜索结果中的帖子总数。
管理这个的插件使用全局 $wp_query 来确定帖子的数量,而不是自定义查询。默认情况下,它的工作方式如下:
function wp_page_numbers($start = "", $end = "")
{
global $wp_query;
global $max_page;
global $paged;
if ( !$max_page ) { $max_page = $wp_query->max_num_pages; }
if ( !$paged ) { $paged = 1; }
$settings = get_option('wp_page_numbers_array');
$page_of_page = $settings["page_of_page"];
$page_of_page_text = $settings["page_of_page_text"];
$page_of_of = $settings["page_of_of"];
$next_prev_text = $settings["next_prev_text"];
$show_start_end_numbers = $settings["show_start_end_numbers"];
$show_page_numbers = $settings["show_page_numbers"];
$limit_pages = $settings["limit_pages"];
$nextpage = $settings["nextpage"];
$prevpage = $settings["prevpage"];
$startspace = $settings["startspace"];
$endspace = $settings["endspace"];
if( $nextpage == "" ) { $nextpage = ">"; }
if( $prevpage == "" ) { $prevpage = "<"; }
if( $startspace == "" ) { $startspace = "..."; }
if( $endspace == "" ) { $endspace = "..."; }
if($limit_pages == "") { $limit_pages = "10"; }
elseif ( $limit_pages == "0" ) { $limit_pages = $max_page; }
我尝试将其修改为:
if ($gallery_query){ $page_query=$gallery_query; }else {$page_query=$wp_query;}
global $max_page;
global $paged;
if ( !$max_page ) { $max_page = $page_query->max_num_pages; }
if ( !$paged ) { $paged = 1; }
但这不会返回任何页面。
理想情况下,我应该用 $gallery_query 值替换 $wp_query 值,但我不知道如何。显而易见的$wp_query = $gallery_query
不起作用。
有什么建议么?
谢谢!
泰