• I have the following piece of code in my home.php

    <?php if (have_posts()) : while (have_posts()) : the_post();
      if($post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>

    It cycles through and displays single posts from any category. I want to change that so it only displays a specific category – category 3

    The entire code looks like this…but I think the above part is where I need to make the changes.

    <!--Begin recent post (single)-->
    
    <?php if (have_posts()) : while (have_posts()) : the_post();
      if($post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
    
    <?php static $ctr = 0;
    if ($ctr == "$artsee_homepage_posts;") { break; }
    else { ?>
    
    <?php
    // check for thumbnail
    $thumb = get_post_meta($post->ID, 'Thumbnail', $single = true);
    // check for thumbnail class
    $thumb_class = get_post_meta($post->ID, 'Thumbnail Class', $single = true);
    // check for thumbnail alt text
    $thumb_alt = get_post_meta($post->ID, 'Thumbnail Alt', $single = true);
    ?>
    <div class="home-post-wrap2">
    <span class="headings">Network</span>
    <div class="post-info">Posted by <?php the_author() ?>  on  <?php the_time('m jS, Y') ?> |  <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></div>
    <span class="titles"><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></span>
    <div style="clear: both;"></div>
    <!--Display thumbnail if found-->
    <div class="thumbnail-div-home">
    <?php // if there's a thumbnail
    if($thumb !== '') { ?>
    <a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/phpThumb/phpThumb.php?src=<?php echo $thumb; ?>&amp;h=130&amp;w=281&amp;zc=1&amp;q=100" alt="<?php if($thumb_alt !== '') { echo $thumb_alt; } else { echo the_title(); } ?>"  style="border: none;" /></a>
    <?php } // end if statement
    // if there's not a thumbnail
    else { echo ''; } ?>
    </div>
    <!--End display thumbnail if found-->
    <?php if (function_exists('the_content_limit')) { the_content_limit(400, ""); } else { echo 'You have not uploaded and acivated the limit posts plugin. This is required.'; } ?>
    <div class="readmore"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Read More</a></div>
    </div>
    
    <?php $ctr++; } ?>
    
    <?php endwhile; ?>
    <!--end recent post (single)-->
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Display posts from specific category within loop’ is closed to new replies.