功能主题为wordpress,帮助编辑某些东西

时间:2010-12-25 00:01:29

标签: php wordpress wordpress-theming

我一直在安装Wordpress主题,主题有自定义导航功能。 它显示归档的页面导航,类别但不显示在标记处。

这是来自functions.php

的功能
<?php  function wp_pagenavi($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) {
 global $request, $posts_per_page, $wpdb, $paged;
 if(empty($prelabel)) {   $prelabel = '<strong>&laquo;</strong>';
 } if(empty($nxtlabel)) {
 $nxtlabel = '<strong>&raquo;</strong>';
 } $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 <div class='Nav'><span>Pages ($max_page): </span>";   if ($paged >= ($pages_to_show-1)) {
 echo '<a href="'.get_pagenum_link().'">&laquo; First</a> ... ';  }
 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 "<strong class='on'>$i</strong>";
 } else {
 echo ' <a href="'.get_pagenum_link($i).'">'.$i.'</a> ';   }
 }
 }
 next_posts_link($nxtlabel, $max_page);
 if (($paged+$half_pages_to_show) < ($max_page)) {
 echo ' ... <a href="'.get_pagenum_link($max_page).'">Last &raquo;</a>';   }
 echo "</div> $after";
 }
 }
}
?>

我希望有人帮助这个功能在标签上显示页面导航,谢谢。

1 个答案:

答案 0 :(得分:0)

这是错误的比赛。将if(!is_category())更改为if(!is_category()&&!is_tag())