• Hi, I’m totally new at WP but got a freelance with it and don’t understand where is the problem with this issue.
    The problem is I need to add a pagination system to this website, I’m trying with WP-Paginate, it seems to be working because is displaying a lot of page’s numbers at the bottom but no matter which one I click it always return the info of the first page, the link changes, but the displayed page is always the same
    here is the code:

    <div class="newsPage">
    	<?php $query = new WP_Query( 'cat=7&posts_per_page=1' ); ?>
    	<?php while ( $query->have_posts() ) : $query->the_post(); ?>
    	<div class="podcastImage"><a href="<?php the_permalink(); ?>"><img src="/wp-content/themes/mmaoddsbreaker2/images/dynamics-liveOdds/podcast1.png" width="100" height="124"></a></div>
    	<?php endwhile; ?>
    	<section>
    		<!--<img src="/wp-content/themes/mmaoddsbreaker2/images/dynamics-news/newsBg.png" width="419" height="422" align="right" class="newsBG"> -->
    		<h1>News</h1>
    		<p class="specialNewsTitle">The Latest <span>MMA News, MMA Previews</span> & Breaking <span>MMA Odds</span> Information!</p>
    		<div class="article-wrap">
    			<?php /* Start the Loop */ ?>
    			<?php $is_odd_post = true; ?>
    			<?php $query = new WP_Query( 'cat=3' ); ?>
    			<?php while ( $query->have_posts() ) : $query->the_post(); ?>
    			<article <?php if ($is_odd_post) { ?> class="odd"<?php $is_odd_post = false; } else { $is_odd_post = true; } ?>>
    				<header>
    					<div class="thAligned">
    						<div class="newsHeadline"> <a href="<?php the_permalink(); ?>">
    							<?php
    								if(get_the_post_thumbnail()){
    									echo get_the_post_thumbnail($post_id);
    								}else{
    									echo get_avatar( get_the_author_meta('ID'), 460 );
    								}
    							?>
    							</a>
    							<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    						</div>
    					</div>
    					<div class="articleDescription">
    						<?php the_excerpt(); ?>
    						<p class="authorInfo"> By
    							<?php the_author(); ?>
    							/ MMAOddsbreaker.com Staff Writer /
    							<?php the_time( "M j, Y" ); ?>
    						</p>
    					</div>
    				</header>
    			</article>
    			<?php endwhile; ?>
    			<?php // if(function_exists('wp_paginate')) {wp_paginate();} ?>
    			<?php // Reset Post Data ?>
    			<?php wp_reset_postdata(); ?>
    		</div>
    		<!--! end of .article-wrap -->
    		<?php include("sideBar.php"); ?>
    	</section>
    	<?php if(function_exists('wp_paginate')) {
    		wp_paginate('range=10&anchor=2&nextpage=Next&previouspage=Previous');
    	} ?>
    </div>

    Can someone give me an idea about how to fix this?

    Thanks in advance.

    Juan Luis Ramirez.

    https://www.ads-software.com/extend/plugins/wp-paginate/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter ViperMasse

    (@vipermasse)

    You can see what I mean here: WP-Paginate Problems at MMAOddsBreaker

    Did you find a solution to this? I’m having a similar problem. When I click a page number it just goes to the homepage. I’ve used the plugin on several other sites without any trouble, so I’m a little confused.

    Update: the problem appears to be only on my search results template. Pagination works fine on the blog posts index.

    I am having the exactly same problem! I’ve installed the plugin and added the wp_paginate() code at the bottom of my list of posts, and so far it works. However, every time I click on a number in the pagination it just reloads the page and lists the same posts again. The URL changes to /page/2/ but it doesn’t list the previous pages as it’s supposed to. I checked your site and it seems to work fine, how did you solve it?

    My code;

    <?php
      $temp = $wp_query;
      $wp_query= null;
      $wp_query = new WP_Query();
      $wp_query->query('showposts=5'.'order=DESC'.'&paged='.$paged);
    ?>
    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
      <div class="news">
        <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'thumb' ); } ?>
        <h3><?php the_title(); ?></h3>
        <p><?php echo strip_tags(get_the_excerpt()); ?></p>
        <div class="readmore"><a href="<?php the_permalink();?>">l?s mer</a></div>
        <div class="date">
          <?php date('Y-m-d'); ?> | <?php post_reply_link(); ?> | <a href="https://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>" target="blank">dela</a>
        </div>
      </div>
    <?php endwhile; ?>
      <?php if(function_exists('wp_paginate')) {wp_paginate();} ?>
      <?php wp_reset_postdata(); ?>
    <?php $wp_query = null; $wp_query = $temp;?>

    Thread Starter ViperMasse

    (@vipermasse)

    I have found this and at least for me is working now ??

    https://stylizedweb.com/2008/08/13/query_posts-pagination-problem/

    Thread Starter ViperMasse

    (@vipermasse)

    This is basically the fix

    You have
    
    <?php if (have_posts()) : ?>
        <?php query_posts("category_name=somecat"); ?>
            <?php while (have_posts()) : the_post(); ?>  
    
    replace with 
    
    <?php if (have_posts()) : ?>
         <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("category_name=somecat&paged=$paged"); ?>
            <?php while (have_posts()) : the_post(); ?>

    I’m having this same problem and the fix posted doesn’t work for me.

    I’m new to WordPress and could really do with some help to get this going.

    <?php get_header(); ?>
    
    		<section>
    
    			<?php query_posts(); the_post(); ?>
    
    			<div class="date-padding"><time class="date" datetime="<?php the_time('Y-m-d'); ?>">
    				<?php the_date(); ?></time>
    			</div>
    
    			<?php wp_reset_query(); ?>
    
    			<div class="video-class">	
    
    			<figure class="videos-main">
    
    				<?php query_posts('posts_per_page=6&cat=-22');
    
    				if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    						<div class="grid-1-2 video-class">
    							<a class="videohover" href="<?php the_permalink(); ?>">
    							<?php get_the_image( array( 'meta_key' => array( 'Thumbnail', 'thumbnail' ), 'size' => 'full' ) ); ?></a>
    							<h2 class="video-title-label"><span class="title-video">
    							<?php if (function_exists('get_cat_icon_lite')) echo get_cat_icon_lite('class=icon-video-title') ;the_title(); ?></span></h2>
    							<div class="para-video"><p><?php the_excerpt(); ?></p></div>
    						</div>
    				</article>
    
    				<?php endwhile; endif; ?>
    
    			</figure>
    
    			</div>
    
    <!--Pagination-->
    <?php echo paginate_links( $args ) ?>
    <?php
    global $wp_query;
    
    $big = 999999999; // need an unlikely integer
    
    echo paginate_links( array(
    	'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    	'format' => '?paged=%#%',
    	'current' => max( 1, get_query_var('paged') ),
    	'total' => $wp_query->max_num_pages
    ) );
    ?>
    
    		</section>
    
    <?php get_sidebar(); ?>

    Do I need to set up a different page for this to work?

    I’m using a random bit of for the pagination I found online. I’ve tried many. They all have the same result.

    Also when I put the code inside the loop, every post gets the pagination displayed next to the title, very strange. It still doesn’t work though.

    Really really appreciate any help on this please!

    thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WP-Paginate returning always the same page’ is closed to new replies.