帮忙解决wordpress中的一些问题,谢谢!

2025-12-16 16:20:59
推荐回答(2个)
回答1:

放弃“上一页”,“下一页”吧,直接用分页好了,下面的代码添加到 functions.php 中
//page navi
function fvcity_pagenavi($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) {
global $request, $posts_per_page, $wpdb, $paged;
if(empty($prelabel)) {
$prelabel = '«';
}
if(empty($nxtlabel)) {
$nxtlabel = '»';
}
$half_pages_to_show = round($pages_to_show/2);
if (!is_single()) {
if(!is_category()) {
preg_match('#FROM\s(.*)\sORDER BY#siU', $request, $matches);
} else {
preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches);
}
$fromwhere = $matches[1];
$numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
$max_page = ceil($numposts /$posts_per_page);
if(empty($paged)) {
$paged = 1;
}
if($max_page > 1 || $always_show) {
echo "$before 页面 ($max_page) :  « ";
if ($paged >= ($pages_to_show-1)) {
echo '« First ... ';
}
previous_posts_link($prelabel);
for($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) {
if ($i >= 1 && $i <= $max_page) {
if($i == $paged) {
echo "$i";
} else {
echo ' '.$i.' ';
}
}
}
next_posts_link($nxtlabel, $max_page);
if (($paged+$half_pages_to_show) < ($max_page)) {
echo ' ... Last »';
}
echo "
$after";
}
}
}
?>

然后在 index.php 里的



之间插入


样式表里对 #pagenavi{} 美化一下就行了

回答2:

是不是要重装系统啊