• I have created a page template that is used by all my pages and it calls in “recent posts”. I have used category-visibility plugin to limit which post are shown on the frontpage but now want to limit posts shown on my “pages”. For example page1 should only show posts for category1. Here is my page template as of now:

    <?php
    /*
    Template Name: sportpage
    */
    ?>
    
    <?php get_header(); ?>
    
    	<div id="content" class="narrowcolumn">
    
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    		<h2><?php the_title(); ?></h2>
    			<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>
    		</div>
    		<?php endwhile; endif; ?>
    	<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    
            <!-- start posts -->
    
        <?php $recentposts = new WP_Query('showposts=3&offset=1');
    		  if($recentposts->have_posts()) : while($recentposts->have_posts()) : $recentposts->the_post(); ?>
    
    					<div class="post" id="post-<?php the_ID(); ?>">
    						<div class="posttitle">
    				 			<h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    							<p class="meta">
    								<?php the_time('F'); ?> <?php the_time('jS Y'); ?> under <?php the_category(' &amp; ') ?> <?php edit_post_link(); ?></p>
    						</div>
    						<div class="postcontent">
    							<?php the_excerpt(); ?>
    						</div>
    						<div class="postfeedback">
    							<?php wp_link_pages(); ?>
    							<?php comments_popup_link('Comments (0)', 'Comments (1)', 'Comments (%)', 'commentlink', ''); ?>
    						</div>
    					</div>
    
    					<?php endwhile; endif; ?>
    
                        <!-- end posts-->
    	</div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter devo420

    (@devo420)

    Ok, I have changed line 27 to look like this:

    <?php $recentposts = new WP_Query('cat=11,&showposts=3&offset=1');

    by adding cat=11 I have got the page displaying certain posts but how do I go about setting it so when they click on the link in the sidebar it uses the proper cat=# ?

    Kind Regards,

    Devin

    Thread Starter devo420

    (@devo420)

    Anyone? I am soo close, please help!

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

The topic ‘specifying which category to post’ is closed to new replies.