如何将一些自定义url参数插入分页链接?下面的代码显示如下
page.php?cpage=2
但我想添加一个参数
category
有价值的
fruit
. 因此,最终的url如下所示。
page.php?cpage=2&category=fruits
等等
page.php?cpage=2&category=fruits&color=red&size=small
在何处以及如何插入代码以实现上述操作?
echo paginate_links( array(
\'base\' => add_query_arg( \'cpage\', \'%#%\' ),
\'format\' => \'\',
\'prev_text\' => __(\'«\'),
\'next_text\' => __(\'»\'),
\'total\' => ceil($total / $items_per_page),
\'current\' => $page
));
提前感谢
SO网友:Milo
使用add_args
要向其中添加查询字符串参数数组的参数pagination links:
echo paginate_links( array(
\'base\' => add_query_arg( \'cpage\', \'%#%\' ),
\'format\' => \'\',
\'prev_text\' => __(\'«\'),
\'next_text\' => __(\'»\'),
\'total\' => ceil($total / $items_per_page),
\'current\' => $page,
\'add_args\' => array(
\'category\' => \'fruit\',
\'color\' => \'red\'
)
));