• Resolved James Brow

    (@james-brow)


    So I’ve been reading the codex for a few days now and I keep seeing similar questions in reference to what I’d like to do with my site, but nothing has stuck out as a solution yet.

    That being the case I was hoping some one could point me in the direction of how I can achieve the desired effect I’m going for.

    Basically on my index page I have 4 sections, Articles/Repair/Web/Design and what I want to be able to do is have each section ONLY update with posts from the appropriate category. That is to say if I write a post and categorize it as an ‘article’ then it only shows in the “Articles” section.

    Is there a plugin or a PHP call for this? What’s more is there one that won’t get tripped up by 4 instances of it running on the same page? I’m not looking to make 4 separate pages-one for each category-I want it all displayed on the main page.

    Any help would be appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter James Brow

    (@james-brow)

    Of course after I post this I figured this part out.

    A snippet. I just put this in each section and changed the cat=# to the appropriate number for each section/category.

    <?php $blog_query = 'showposts=4&cat=7';
    	$posts = query_posts($blog_query);
    	while (have_posts()) : the_post(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    			<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    			<div class="entry">
    				<?php the_excerpt(); ?>
    				<p class="postmetadata">
    <?php the_category(', ') ?> <?php _e('by'); ?> <?php  the_author(); ?>
    <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> <?php edit_post_link('Edit', ' | ', ''); ?>
    				</p>
    			</div>
    			<div class="comments-template">
    <?php comments_template(); ?>
    </div>
    		</div>
    	<?php endwhile; ?>
    		<div class="navigation">
    			<h6><?php posts_nav_link(); ?></h6>
    		</div>
    
    		<div class="post">
    			<h2><?php _e('Not Found'); ?></h2>
    		</div>

    not sure if it will work multiple times on the same page yet.

    Thread Starter James Brow

    (@james-brow)

    It works. Closing.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Displaying multiple posts by categories?’ is closed to new replies.