WordPress.org

Ready to get started?Download WordPress

Forums

Tag page pagination problem (5 posts)

  1. Zyama
    Member
    Posted 6 years ago #

    I am using Dilectio theme.

    There is small bug: there is no pagination appears after pressing any tag. It lists only 10 (or defined number) of related posts even if there are much more posts for this tag.

    For example http://hinkal.ru/tag/dagestan/
    There are 39 posts for tag “daghestan” at the moment but shows only 10 of them. Is there any idea how to fix this?

    Thanks a lot.

  2. iridiax
    Member
    Posted 6 years ago #

    Your theme needs to have <?php posts_nav_link(); ?> added to whatever template page displays your tags.

    http://codex.wordpress.org/Next_and_Previous_Links

  3. Zyama
    Member
    Posted 6 years ago #

    It is the same page for archieves and tags, but pagination does not work for tags

    <?php get_header(); ?>
    <!-- Container -->
    <div class="CON">
    
    <!-- Start SC -->
    <div class="SC">
    <?php is_tag(); ?>
    		<?php if (have_posts()) : ?>
    
     	  <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
     	  <?php /* If this is a category archive */ if (is_category()) { ?>
    		<h2 class="pagetitle">Архив категории ‘<?php single_cat_title(); ?>’</h2>
     	  <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
    		<h2 class="pagetitle">Сообщения с тегами ‘<?php single_tag_title(); ?>’</h2>
     	  <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    		<h2 class="pagetitle">Архив за <?php the_time('F jS, Y'); ?></h2>
     	  <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    		<h2 class="pagetitle">Архив за <?php the_time('F, Y'); ?></h2>
     	  <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    		<h2 class="pagetitle">Архив за <?php the_time('Y'); ?> год</h2>
    	  <?php /* If this is an author archive */ } elseif (is_author()) { ?>
    		<h2 class="pagetitle">Архив сообщений автора</h2>
     	  <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
    		<h2 class="pagetitle">Архивы блога</h2>
     	  <?php } ?>
    
    <!-- Start Nav -->
    <?php if (function_exists('wp_pagenavi')) { ?><?php wp_pagenavi(); ?><?php } ?>
    <!-- End Nav -->
    
    <?php while (have_posts()) : the_post(); ?>
    <div class="Post" id="post-<?php the_ID(); ?>" style="padding: 5px 0px;">
    <div class="PostHead" style="margin-left: 0px;">
    <h3><a title="Постоянная ссылка на <?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    <small class="PostAuthor">От: <?php the_author() ?> : <?php the_time('M j,Y') ?></small>
    <small class="PostCat">В: <?php the_category(', ') ?></small>
    </div>
    
    </div>
    <?php endwhile; ?>
    
    <!-- Start Nav -->
    <?php if (function_exists('wp_pagenavi')) { ?><?php wp_pagenavi(); ?><?php } ?>
    <!-- End Nav -->
    
    <?php else : ?>
    
    <h2 class="pagetitle">Не найдено</h2>
    <?php endif; ?>
    
    </div>
    <!-- End SC -->
    
    <?php get_sidebar(); ?>
    </div>
    <!-- End CON -->
    
    <?php get_footer(); ?>
  4. Zyama
    Member
    Posted 6 years ago #

    May be the problem in page-navi function in function 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>Страниц ($max_page): </span>";
    			if ($paged >= ($pages_to_show-1)) {
    				echo '<a href="'.get_pagenum_link().'">&laquo; В начало</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).'">В конец &raquo;</a>';
    			}
    			echo "</div> $after";
    		}
    	}
    }
  5. Zyama
    Member
    Posted 5 years ago #

    I solved this problem by deleting page-navi function in function php and addind Page-Navi plugin.

    There was minor problem with css styles, but it take 10 minut to rewrite them.

Topic Closed

This topic has been closed to new replies.

About this Topic