ThemeShaper Forums » Thematic

[closed]

Adding Title to whole Loop, as distinct from individual posts

(2 posts)
  • Started 3 years ago by RichardB
  • Latest reply from helgatheviking
  • This topic is not resolved

Tags:

  1. RichardB
    Member

    Hi everyone.

    I've got a couple of loops working on my test site home page (www.lichfieldfestival.org/testingtestingtesting), and would like the second one to have a title: 'Latest News', as Ian has for the 'recent items from the blog' bit of this: http://themeshaper.com/2009/02/02/custom-page-template-redesign-blog/. I'd also like to style these posts separately to the featured posts above. Is there a way of doing these things? Thank you.

    For reference, here's the code for the loops in my child theme functions.php:

    // Add featured posts to the frontpage underneath the featured content slideshow
    function LFS_indexloop() {
    get_posts("showposts=3&cat=349");
    if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
    <?php
    if (has_post_thumbnail()) {
    the_post_thumbnail('homepage-featured-image');
    } thematic_postheader();?>
    </div><!-- .post -->
    <?php endwhile; else: ?>
    <h2>Eek</h2>
    <p>There are no posts to show!</p>
    <?php endif;
    wp_reset_query();
    }

    // Add Latest News loop underneath the featured posts
    function LFS_Latest_News() {
    get_posts("posts_per_page=3&cat=31");
    if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div id="post-<?php the_ID() ?>" class="<php thematic_post_class() ?>">
    <h3>Latest News</h3>
    <?php thematic_postheader();
    if (has_post_thumbnail()) {
    the_post_thumbnail('latest-news-image');
    }?></div>
    <div class="entry-content">
    <?php the_excerpt(); ?>
    " class="more"><?php echo more_text() ?>
    </div><!--.post-->
    <?php endwhile; else: ?>
    <h2>Oh dear!</h2>
    <p> Nothing's happening here right now, call again later.</p>
    <?php endif;
    wp_reset_query();
    }

    Posted 3 years ago #
  2. separate the IF and WHILE and insert your title between them:

    // Add Latest News loop underneath the featured posts
    function LFS_Latest_News() {
    get_posts("posts_per_page=3&cat=31");
    if (have_posts()) : 
    
    echo "<h2>Build a Bacon Fortress to Keep the Haters Away</h2>";
    
    while (have_posts()) : the_post(); ?>
    <div id="post-<?php the_ID() ?>" class="<php thematic_post_class() ?>">
    <h3>Latest News</h3>
    <?php thematic_postheader();
    if (has_post_thumbnail()) {
    the_post_thumbnail('latest-news-image');
    }?></div>
    <div class="entry-content">
    <?php the_excerpt(); ?>
    " class="more"><?php echo more_text() ?>
    </div><!--.post-->
    <?php endwhile; else: ?>
    <h2>Oh dear!</h2>
    <p> Nothing's happening here right now, call again later.</p>
    <?php endif;
    wp_reset_query();
    }
    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.