I am using coding I found and modified that adds the content of posts to the end of a page, where the category of the post matches the name of the page. In other words, The Page is called “Test” So all posts with the category “Test” will be added at the end of the page.
This allows me to Have a quick introduction about the content of the posts, before showing the posts. (the original code included the name of the posts as well, but I did not need it, so I took it out.)
The problem is this: One the rest of the site, I want only the most recent post to show up on any given page. But on pages that use this template, I want all the posts (or at least the last 25 or so) to show up. So what do I have to add to this code to do that?
<?php /* Template Name: CategoryPostPage */ ?> <?php get_header(); ?> <div id="content"> <div id="main"> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; else: endif; ?> <?php query_posts('category_name='.get_the_title().'&post_status=publish,future');?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <p><?php the_content(); ?> <?php endwhile; else: endif; ?> </div> </div> <?php get_footer(); ?>
I tried adding
I assumed they should be added within the query_post() parameters, but that doesn’t seem to be working. I tried adding a separate Query_post() function, but that seemd to just override the first, and list every post out there…
What am I missing?
- The topic ‘Over-ride "Posts per Page using special coding’ is closed to new replies.