在我的网站上,以下数组参数可以通过ajax请求中的WordPress query_posts()函数正常工作:
$arr_params= array
(
'post_type'=>'university',
'tax_query' => array(
array(
'taxonomy' => 'uni',
'field' => 'slug',
'terms' => 'stanford'
)
)
);
但是,是否可以使用这些参数构建链接?我想在我的帖子上显示一个链接,单击该链接后,使用上述参数重新加载WordPress循环。
我试过了
add_query_arg($arr_params,get_permalink());
但没有任何成功
add_query_arg 函数不采用问题中显示的分类查询。以下数组产生了我想要的结果:
$arr_params= array
(
'post_type'=>'university',
'taxonomy' => 'uni',
'terms' => 'stanford'
);
echo add_query_arg($arr_params);
这是它返回的内容:
/?post_type=大学&分类法=Uni&terms=斯坦福大学