WordPress.org

Ready to get started?Download WordPress

Forums

query_posts, display 1 page and posts from select category? (2 posts)

  1. Wolfull
    Member
    Posted 6 years ago #

    On one of my pages I would like to display the contents of the page followed by all posts made in a specific category..

    So

    Header
    -Page Contents
    -Category 1
    --Post1
    --Post2
    --etc etc

    I can use in the pages template query_posts('cat=X'); to display all the posts in the selected category but as soon as I do the template doesn't display the page contents.

    So i was thinking maybe you could combine the query_posts with a page? query_posts('page_id=160&cat=X')

    But sadly it doesn't work, does anyone have advice on how to do this?
    Cheer

  2. glaze0101
    Member
    Posted 6 years ago #

    I do something similar however, I cant figure out how to put in the navigation when I have more than 15 posts (i.e. to see the next 15 older posts) Other than that this works:

    <?php get_header(); ?>
    
    	<div id="content" class="narrowcolumn">
    
    	<div id="entry">
    
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    		<div class="post" id="post-<?php the_ID(); ?>">
    
    		<div class="content_top">
    			<h2><?php the_title(); ?></h2>
    		</div>
    
    			<div class="entry">
    
    				<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    
    				<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    
    			<div class="search">
    			Search: <?php include (TEMPLATEPATH . '/searchform.php'); ?>
    			</div>
    
     <?php
     $lastposts = get_posts('numberposts=15&category=17&orderby=ID&order=ASC');
     foreach($lastposts as $post) :
        setup_postdata($post);
     ?>
    <div id="subentry">
    <?php global $more;
    $more = 0; ?>
     <h3><em><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></em></h3>
    <p><?php the_excerpt(); ?>
    <p><a href="<?php the_permalink() ?>">Read more of what God says about "<?php the_title(); ?>" ...</a>
    </p><div class="line"></div></p>
    </div>
     <?php endforeach; ?>
    
    		</div>
    
    		<?php endwhile; endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags