WordPress.org

Ready to get started?Download WordPress

Forums

Multiple Loops pagination problem with custom permalinks (5 posts)

  1. webdesignetc
    Member
    Posted 3 years ago #

    Good morning everybody,

    I have run into a problem which is quite strange. I have setup a personal theme with a single.php, where I use multiple loops - one loop for displaying the actual post - with pagination back and forward - and one loop for displaying all posts in this category - with pagination back and forward (which will change the listing of all posts).

    The problem is with the second loop (all posts in current category):
    It works fine when I'm using the standard permalink option like:

    http://www.foto-gschwandtner.at/?p=235

    When it comes to pagination WordPress adds "&paged=2" at the end of the URL

    http://www.foto-gschwandtner.at/?p=235&paged=2

    and changes the content of the second loop. Good.
    If I switch to custom permalinks using "/%category%/%postname%/" for example:

    http://www.foto-gschwandtner.at/landschaft/montreux-4/

    the pagination of the second loop doesn't change the URL to
    http://www.foto-gschwandtner.at/landschaft/montreux-4/page/2/
    and does not change the content. Bad.

    Any idea, why it works with standard permalinks but not with custom permalinks? Could it be a WordPress bug?

  2. webdesignetc
    Member
    Posted 3 years ago #

    This is the code:

    <?php
    get_header();
    # get_sidebar();
    ?>
    
         	<?php
    			$category_id = get_the_category();
        		$category_link = get_category_link( $category_id[0]->cat_ID );
    			$category = $category_id[0]->cat_ID;
    		?>
    
              <div id="ContentFrame">
    		  <!-- Single.php -->
    
          		<?php global $query_string;
    			query_posts( $query_string . "&cat=$category&showposts=1" ); ?>
    
    			<?php while (have_posts()) : the_post(); $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 800,9999 ), false ); ?>
    
               <div class="stage">
    		   <div id="Close">
    
                   <a href="<?php echo $category_link; ?>" title="Zur&uuml;ck zur Rubrik"><img src="<?php bloginfo('template_url'); ?>/images/close-x.jpg" width="25" alt="Close"/></a>
    		   </div>
    		   <center><?php echo wpop_image_display(); ?></center>
               </div> <!-- end .stage -->
    			<?php endwhile; ?>
    		   <div class="navigation">
    				<div class="nav_alignright">
    				<?php previous_post_link('%link','&raquo;&raquo;', TRUE); ?>
                        </div>  
    
    				<div class="nav_alignleft">
    				<?php next_post_link('%link','&laquo;&laquo;', TRUE); ?>
                    </div>
              	</div>	
    
    		<center>
    
    		<?php
    
    		$cat = $category;
    		$post_per_page = 8; // -1 shows all posts
      		$do_not_show_stickies = 1; // 0 to show stickies
      		$args=array(
        		'category__in' => array($cat),
        		'orderby' => 'date',
        		'order' => 'DESC',
        		'paged' => $paged,
        		'posts_per_page' => $post_per_page,
        		'caller_get_posts' => $do_not_show_stickies
      		);
    
      		$temp = $wp_query;  // assign orginal query to temp variable for later use
      		$wp_query = null;
      		$wp_query = new WP_Query($args);
      		?>
    
    		<div id="ImageSelection">
            <ul id="ImgRow">
            <?php // echo $paged; ?>
    
    		<?php if( have_posts() ) :
    			while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    
        		<li><a href="<?php echo the_permalink(); ?>"><?php echo get_the_post_thumbnail($post->ID, 'thumbnail'); ?></a></li>
    
    		<?php endwhile;  ?>
    
              </ul>
    
              </div> <!-- end of ImageSelection -->
              </center>
              <center>
              	<div class="ImgNavi">
          			<div class="ImgNaviLeft"><?php previous_posts_link('&laquo;&laquo;') ?></div>
    				<div class="ImgNaviRight"><?php next_posts_link('&raquo;&raquo;') ?></div>
        			</div>
      		</center>
    		<?php else : ?>
    
    		<center>
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		</center>
    
    		<?php endif; ?>
    
    		</div> <!-- end of ContenFrame -->				
    
    <?php get_footer(); ?>
  3. webdesignetc
    Member
    Posted 3 years ago #

    It seams, that WordPress has a problem with pagination of two different loops when it comes to custom permalinks.... Any hints so far?

  4. webdesignetc
    Member
    Posted 3 years ago #

    Good morning again,
    I think today is the perfect day to be helped out here in the forum by somebody.

  5. webdesignetc
    Member
    Posted 3 years ago #

    Hello,

    I think, this topic is it worth, to bring it on top of the cue again. If anybody has a solution for this...... that would be really great.

Topic Closed

This topic has been closed to new replies.

About this Topic