• Resolved tkim1205

    (@tkim1205)


    Hey folks!

    I am new to PHP and WordPress, and I have a simple problem which I’ve been struggling with this past weekend.

    I have a page that shows all posts for a specific category, however it only displays 10 posts.

    How can I have “next 10” / “previous 10” links? Is this a simple solution?

    Thanks! 🙂

    Here is my code so far:

    <?php
    /*
    Template Name: Blog_Page
    */
    ?>

    <?php get_header(); ?>

    <div>
    </br></br>

    <div id=”heading”>
    <h1>Blog Articles<h1>
    <HR width=”750px” color=”#87b2bd” size=”2″>
    </div>

    <div id=”content”>

    <?php
    query_posts(‘cat=4,16’);
    while (have_posts()) : the_post();
    ?>

    <h2>” rel=”bookmark”><?php the_title(); ?></h2>
    </br>
    <span>Date posted: <?php the_date(); ?></span>
    </br></br>
    <p><?php the_excerpt(); ?></p>
    </br>
    <span class=”comment-link”><?php comments_popup_link(‘Leave Comment’, ‘1 Comment’, ‘% Comments’, ‘comments-link’, ”); ?></span>
    </br></br>
    <HR width=”750px” color=”#87b2bd” size=”1″>
    </br></br>

    <?php endwhile; ?>

    </div>

    </div>

Viewing 7 replies - 1 through 7 (of 7 total)
  • I’d love to know the <php> for this also…

    …but in the mean time, I know there are plugins that add those…

    Review:

    query_posts('cat=4,16');

    You are only showing posts with cat id of 4 and 16.

    See this for clarification, tips.

    Yes, I believe that is his intent. He may have 100 posts under those two categories and wants to display only 10 at a time….

    Thread Starter tkim1205

    (@tkim1205)

    Hi thanks for that reply!

    Yep i only want to show posts of cat id 4 and 16, however my issue is there is a total of about 20 posts, but only 10 posts show up on my page. There is no “next” button to retrieve the next 10.

    You can display more if you change your setting in reading (I think it’s at) from 10 to 20… but then you’re making a longer page. I await another answer!

    Sad thing is that if I look up some old documentation I can probably find it… just takes a lot of effort as I’m not 100% sure. lol. It’s simple to add, so someone should help! lol

    Thread Starter tkim1205

    (@tkim1205)

    Found the answer 🙂

    <div id="content">
    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
    <?php query_posts('posts_per_page=5&cat=4,16&paged=' . $paged); ?>
    <?php while (have_posts()) : the_post(); ?>
    <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    <p><?php the_excerpt(); ?></p>
    <?php endwhile; ?>
    </div>
    
    <div class="navigation">
    <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
    else { ?>
    <div class="right"><?php next_posts_link('Next Page &raquo;') ?></div>
    <div class="left"><?php previous_posts_link('&laquo; Previous Page') ?></div>
    <?php } ?>
    </div>

    Perfect, thanks. 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Page for specific Category doesn't display all posts’ is closed to new replies.