• Please help with this problem,
    How will i view the other post from each category? For example i have 10 posts from category 1 and i want to post the first 5, then another link to view the other 5 posts.

    Example view:
    category 1
    posts 1
    posts 2
    posts 3
    posts 4
    posts 5
    More Posts from category 1

Viewing 3 replies - 1 through 3 (of 3 total)
  • <?php
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $tmp = $wp_query;
    $wp_query = new WP_Query("category_name=category 1&posts_per_page=5&paged=".$paged);
    while(have_posts()):
     the_post();
    
     //put the code here according to your design
    
    endwhile;
    $wp_query = $tmp;
    ?>
    Thread Starter darwinsantos24

    (@darwinsantos24)

    can you please check this code i apply the code that you have written but the it does not appear the more post from category 1

    <div class="title">
    <?php									$paged = get_query_var('paged') ? get_query_var('paged') : 1;
    	$tmp = $my_query;
            $my_query = new WP_Query("category_name=".$cat->cat_name."&posts_per_page=2&paged=".$paged);
            $count = 0;
            while($my_query->have_posts()) : $my_query->the_post();
            $count++;
            if ($count <=1 ) :
    ?>
            <h2><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h2>
    </div>
    <div class="sentry">
            <?php the_excerpt(); ?>
            <?php else : ?>
              	<li><?php the_title(); ?></li>
            <?php endif; ?>
            <?php endwhile; $my_query = $tmp; ?>
    </div>
    <div class="title">
    <?php									$paged = get_query_var('paged') ? get_query_var('paged') : 1;
    	$tmp = $wp_query;
            $wp_query = new WP_Query("category_name=".$cat->name."&posts_per_page=2&paged=".$paged);
            $count = 0;
            while(have_posts()) : the_post();
            $count++;
            if ($count <=1 ) :
    ?>
            <h2><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h2>
    </div>
    <div class="sentry">
            <?php the_excerpt(); ?>
            <?php else : ?>
              	<li><?php the_title(); ?></li>
            <?php endif; ?>
            <?php endwhile; $wp_query = $tmp; ?>
    </div>

    Try this once;

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Post Per Category’ is closed to new replies.