Support » Fixing WordPress » Adding Category Specific Posts to a Page

  • Hello all, I’m a Teaching Assistant at URI, and I’m trying to setup a website for a professor, using WordPress as the backbone. My plan is to organize all his classes in to one webpage with links to each individual class page which will contain a Blog for the class, syllabus, and schedule.

    On my Class blog page I’am trying to format my page.php page to identify the page the user is currently on and to display specific blog posts based on that category.
    Here is the code I’m working with:

    <?php
    	if(is_page('COM520- Media and Emotions'))
    		{
    			 if (have_posts(in_category('2'))) : ?>
    		<?php while (have_posts()) : the_post(); ?>
    			<div class="post" id="post-<?php the_ID(); ?>">
    
    				<h1><?php the_title(); ?></h1>
    
    				<div class="post_body">
    
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    
    				</div>
    
    			</div>
    
    		<?php endwhile; ?>
    
    	<?php else : ?>
    
    			<h1>Not Found</h1>
    
    			<p>Sorry, but you are looking for something that isn't here.</p>
    
    	<?php endif;
    		}

    So Its saying if the page is COM520 display category ‘2’ posts. But its not displaying them. Where do I need to put the category identifier in the code?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding Category Specific Posts to a Page’ is closed to new replies.