• Resolved matthijs_b

    (@matthijs_b)


    Hi, wanted a page named ‘galerie’ to show all posts from one category so I added this bit of logic to my page.php:

    if (is_page('galerie')) {
     $galposts = get_posts('category=3');
     foreach($galposts as $post) :
        setup_postdata($post);
     ?>
     <h2><a>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
     	<div class="thecontent"><?php the_content(); ?></div>
    	<div class="postspace">	</div>
     	<?php endforeach; ?>
    	</div>
    	<?php
    } else {

    However it shows only the last five (5) posts. Why? And what to do to make it show all!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Don’t know about get_posts, but the template tag, query_posts(), offers the parameter, posts_per_page=-1

    Here’s an example of how I usually make a list of posts for a certain category, without the_content. You can fiddle with it to suite your needs. This should show the category “Galerie” (case sensitive) and up to 99999999 posts.

    <div class="outterdiv">
    <?php if (have_posts()) : ?>
    <h2>Galerie</h2>
    <?php $temp_query = $wp_query; ?>
    <?php query_posts('category_name=Galerie&showposts=99999999'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <ul><li class="style1"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li></ul>
    </div>
    <?php endwhile; ?>
    <?php else : ?>
    <h2 class="center">Not Found</h2>
    <p class="center">Sorry, but you are looking for something that isn't here.
    <?php endif; ?>
    </div>
    Thread Starter matthijs_b

    (@matthijs_b)

    Ah, thanx a lot. Still very curious why my thing limited it to five posts, but jbrndt ‘s suggestion works. Thanx a lot!
    I’m using it as follows:

    <?php
    if (is_page('galerie')) {
    	query_posts('category_name=galerie&showposts=99999999'); ?>
    	<?php while (have_posts()) : the_post(); ?>
    
    		<div class="post" id="post-<?php the_ID(); ?>">
    		<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    					<?php the_title(); ?></a></h2><br />
    					<div class="thecontent"><?php the_content(); ?></div>
    					<div class="postspace">	</div>
    		</div>
    	<?php endwhile; ?>
    <?php
    } else { ...

    Does this suppose “next entries” and “previous entries” button?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘show *ALL* posts from one category, not just 5’ is closed to new replies.