• Resolved therizone

    (@therizone)


    Hey everyone,

    I apologise for being a novice at this because I can find a lot of relative information about this in the help and on many previous posts but I can’t seem to find/understand a close enough simple solution (i’m a php newbie).

    What I’m looking for is a simple customised loop, so when I load my index.php, instead of it loading up the most recent posts, I want it to display exactly the same (full post with title and date) but only posts from a category that I specify.

    Simple, static, I don’t think it should be very hard.

    This is my loop, very short (taken comments out etc.)

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <?php the_date('','<h2>','</h2>'); ?>
    
    <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    	 <h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    	<div class="meta"><?php the_category(',') ?>&nbsp;<?php edit_post_link(__('edit')); ?></div>
    
    	<div class="storycontent">
    		<?php the_content(__('(more...)')); ?>
    	</div>

    Now what can I add to that to make filter out a category?

    If any one could help, I’d be very appreciative as I have spent the last 3 days trying to figure this out.

    Cheers

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter therizone

    (@therizone)

    solved, in another thread, by buddah trance

    @ therizone – To have a page display one single category, the regular loop way, I have done it by creating a template and using the following

    <?php if(have_posts()) : ?>
    <?php
    if (is_page()) {
    query_posts(“cat=3”);
    }
    ?>

    <?php while(have_posts()) : the_post(); ?>

    For the home page, I think it would work with

    if (is_home()) instead of if (is_page())

    Thread Starter therizone

    (@therizone)

    solved by buddah trance in another thread, yay

    @ therizone – To have a page display one single category, the regular loop way, I have done it by creating a template and using the following

    <?php if(have_posts()) : ?>
    <?php
    if (is_page()) {
    query_posts(“cat=3”);
    }
    ?>

    <?php while(have_posts()) : the_post(); ?>

    For the home page, I think it would work with

    if (is_home()) instead of if (is_page())

    Thread Starter therizone

    (@therizone)

    solved by buddah trance in another thread, yay

    @ therizone – To have a page display one single category, the regular loop way, I have done it by creating a template and using the following

    <?php if(have_posts()) : ?>
    		<?php
       if (is_page()) {
          query_posts("cat=3");
       }
    ?>
    
    <?php while(have_posts()) : the_post(); ?>

    For the home page, I think it would work with

    if (is_home()) instead of if (is_page())

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘index.php loop to display category specific posts only’ is closed to new replies.