WordPress.org

Support

Support » Plugins and Hacks » Archive Categories with multiple pages

Archive Categories with multiple pages

  • Hello,

    thanks for this great plugin, it helped us a lot in our Website.

    We are using it mainly in our Archive page. I have about ten categories and only the main category works fine. The main category, “Archives” list all post from all categories, while the other categories are more specific.

    When we choose one of theses other categories and click on page 2, it will go back to the main category.

    You can view the section here. The only other category with more than one page is “Mieux-vivre” at the moment.

    Here is the code from the “Mieux-vivre” template part :

    <!-- MIEUX-VIVRE -->
    
    <?php if(is_page('mieux-vivre')): ?>
        <?php echo "<h1>".$post->ID."</h1>"?>  // Showing post ID for quick identification.
    <?php function my_custom_posts_per_page( $my_query ) {
        if (!is_admin() && post_type_exists('mieux-vivre') )
            $my_query->set( 'posts_per_page', 6 );
        }
    
        add_filter('parse_query', 'my_custom_posts_per_page'); ?>
    
                 <!-- The timeline section let you sort post by year -->
    
                 <div class="timeline">
    				<a href="<?php echo get_permalink(241); ?>"<?php if(empty($dateoti)): ?>class="active"<?php endif; ?>>Tous</a>
    				<?php for($i=2012; $i <= date("Y",time()); $i++){ ?>
    					<a href="<?php echo get_permalink(241); echo "annee/"; echo $i; ?>" <?php if(!empty($dateoti) && $dateoti == $i): ?>class="active"<?php endif; ?>><?php echo $i; ?></a>
    				<?php } ?>
    			</div>
    
    			<span class="band"><?php include('bandeau-archives.php'); ?></span>
    <?php $my_query = new WP_Query( array( 'cat' => '5', 'paged' => get_query_var('paged') ) ); ?>
    <?php while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
    
                            <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                            	<a href="<?php the_permalink(); ?>">
    								<?php the_post_thumbnail(  array(172,0,true) ); ?>
                                     <h5>
    								 	<?php if (strlen($post->post_title) > 81) {
    									echo substr(the_title($before = '', $after = '', FALSE), 0, 81) . '...'; } else {
    									the_title();
    									} ?>
                                     </h5>
                                     <p><?php
    									$excerpt = get_the_excerpt();
    									echo string_limit_words($excerpt,15);
                                    ?>...</p>
                                     <p class="date"><?php echo get_the_date(); ?> </p>
                                 </a>
                            </div><!-- #post-## -->
    
                    <?php endwhile; ?>
                   <?php wp_pagenavi( array( 'query' => $my_query ) ); wp_reset_postdata(); ?>
                <?php endif; ?>

    The code for the main category is the same except for the cat ID.
    Can you tell me what’s going wrong ?

    Thanks !

    https://wordpress.org/plugins/wp-pagenavi/

Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Archive Categories with multiple pages’ is closed to new replies.