我试图获得与下图相似的外观,可以在这里找到一个工作示例:http://www.menshealth.com/celebrity-fitness/mark-wahlberg-fighter-workout
The needed code must do the following (some of my questions have been answered, but these remain):
将未链接的活动/当前页码转换为指向页面顶部的链接。
为上一个链接和下一个链接指定唯一的样式类
我当前的代码是in use on this site.
下面的代码是我到目前为止的代码。
给它打电话
<?php
wp_link_pages(array(
\'before\' => \'<p>\' . __(\'\'),
\'after\' => \'</p>\',
\'next_or_number\' => \'next_and_number\', # activate parameter overloading
\'nextpagelink\' => __(\'Next\'),
\'previouspagelink\' => __(\'Previous\'),
\'pagelink\' => \'%\',
\'echo\' => 1 )
);
?>
自定义函数
// Custom Next/Previous Page
add_filter(\'wp_link_pages_args\', \'wp_link_pages_args_prevnext_add\');
/**
* Add prev and next links to a numbered link list
*/
function wp_link_pages_args_prevnext_add($args)
{
global $page, $numpages, $more, $pagenow;
if (!$args[\'next_or_number\'] == \'next_and_number\')
return $args; # exit early
$args[\'next_or_number\'] = \'number\'; # keep numbering for the main part
if (!$more)
return $args; # exit early
if($page-1) # there is a previous page
$args[\'before\'] .= _wp_link_page($page-1)
. $args[\'link_before\']. $args[\'previouspagelink\'] . $args[\'link_after\'] . \'</a>\'
;
if ($page<$numpages) # there is a next page
$args[\'after\'] = _wp_link_page($page+1)
. $args[\'link_before\'] . $args[\'nextpagelink\'] . $args[\'link_after\'] . \'</a>\'
. $args[\'after\']
;
return $args;
}
最合适的回答,由SO网友:Evan Mattson 整理而成
您的分页链接用此标记包装<p class="pagelinks">
因此,使用CSS可以很容易地使它们具有相同的间距,例如:
.pagelinks a { margin: 0 5px !important; } /* override other defined margins */
也许你也希望它们都集中在页面上:
.pagelinks { display:block; text-align:center; }
将当前页码设置为指向页面顶部的链接-在上一页之前/之后尝试此操作(&P);下一页if语句:
if($page == $pagenow) { // check if current link is current page
$args[\'pagelink\'] = \'<a href="#header">%</a>\'; // assuming top div has ID "header"
} else {
$args[\'pagelink\'] = \'%\';
}