• Resolved tocchio

    (@tocchio)


    Hello there,

    as I was developing my blog layout with the plugin “Theme Test Drive”, I had some pagination issues on my template page, but I could solve them all. Now I rolled out my blog, but I got the same problem as before: the pagination function shows the same posts in every page.

    Here is the code from my template page:

    <?php get_header(); ?>
    
    <div id="content">
    
    	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    	<?php endwhile; else: endif; ?>
    
    	<?php $temp = $wp_query; $wp_query= null;
    	$wp_query = new WP_Query(); $wp_query->query('showposts=5' . '&paged='.$paged . '&category_name='.get_the_title());
    
    	while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    
    	<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    
    	<div class="entry-byline">
    		<span <?php hybrid_attr( 'entry-author' ); ?>><?php the_author_posts_link(); ?></span>
    		<time <?php hybrid_attr( 'entry-published' ); ?>><?php echo get_the_date(); ?></time>
    		<?php comments_popup_link( number_format_i18n( 0 ), number_format_i18n( 1 ), '%', 'comments-link', '' ); ?>
    		<?php if ( function_exists( 'ev_post_views' ) ) ev_post_views( array( 'text' => '%s' ) ); ?>
    		<?php edit_post_link(); ?>
    	</div><!-- .entry-byline -->
    
    	<?php
    	global $more;
    	$more = 0;
    	?>
    
    	<?php the_content( 'Mais...' ); ?> 	
    
    	<div align="center"><img src="http://i2.wp.com/www.farofadechucrute.com/wp-content/uploads/2014/07/Separator2.png?resize=600%2C20" border="0"></div>
    
    	<?php endwhile; ?>	
    
    	<p align="center"><?php wpex_pagination(); ?></p>
    
    </div>
    
    <?php get_footer(); ?>

    And here is the pagination functions in my functions.php:

    // Numbered Pagination
    if ( !function_exists( 'wpex_pagination' ) ) {
    
    	function wpex_pagination() {
    
    		$prev_arrow = is_rtl() ? '&rarr' : '<< Anterior';
    		$next_arrow = is_rtl() ? '&larr' : 'Próximo >>';
    
    		global $wp_query;
    		$total = $wp_query->max_num_pages;
    		$big = 999999999; // need an unlikely integer
    		if( $total > 1 )  {
    			 if( !$current_page = get_query_var('paged') )
    				 $current_page = 1;
    			 if( get_option('permalink_structure') ) {
    				 $format = 'page/%#%/';
    			 } else {
    				 $format = '&paged=%#%';
    			 }
    			echo paginate_links(array(
    				'base'			=> str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    				'format'		=> $format,
    				'current'		=> max( 1, get_query_var('paged') ),
    				'total' 		=> $total,
    				'mid_size'		=> 1,
    				'type' 			=> 'plain',
    				'prev_text'		=> $prev_arrow,
    				'next_text'		=> $next_arrow,
    				'before_page_number' 	=> '&nbsp',
    				'after_page_number' 	=> '&nbsp',
    			 ) );
    		}
    	}
    
    }

    What am I doing wrong? Can another function somewhere inside my child theme block the pagination function?

    Thanks in advance

    Cheers
    Felipe

Viewing 1 replies (of 1 total)
  • Thread Starter tocchio

    (@tocchio)

    I got it! I changed my query to this:

    <?php if ( get_query_var( 'paged' ) ) {
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	} else {
    	$paged = (get_query_var('page')) ? get_query_var('page') : 1;
    	}
    	?>
    
    	<?php query_posts('category_name='.get_the_title().'&post_status=publish&paged=' . $paged);?>
Viewing 1 replies (of 1 total)
  • The topic ‘Pagination shows same posts’ is closed to new replies.