ThemeShaper Forums » Thematic

[closed]

Showing first news item as full and rest as titles

(8 posts)
  • Started 7 years ago by proto
  • Latest reply from helgatheviking
  • This topic is resolved
  1. proto
    Member

    Hello all,

    I'm wondering if any kind folks can help me. I am looking to use my loop to output a category (in this case news) on my homepage. So far so good. I would like to ouput my news category posts with the first one as an excerpt and then after the excerpt have the next news post appear as just a title. Here's the loop, I've come up with which uses a counter to display which one to output (I know something's wrong but not sure what after trying a few variations!):

    <div id="rowTwo" class="grid_12"></div>
        <?php query_posts('category_name=news&posts_per_page=2');?>
    <?php while (have_posts()) : the_post(); ?>
    <?php $counter++; ?>
     <div id="<?php if ($counter == 1) { echo'newsone" class="grid_4'; } ?>">
    <?php thematic_postheader();?>
    <div class="entry-content">
    <?php
          if (has_post_thumbnail()) {
            the_post_thumbnail('home_pic');
          } ?>
    		<?php the_excerpt(); ?>
    
           <a href="<?php the_permalink(); ?>" class="more">
    <?php echo more_text() ?></a>
        </div><!-- end of Entry Content -->
      <?php endwhile; ?>
       <?php else : ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php $counter++; ?>
     <div id="<?php if ($counter == 2) { echo'newstwo" class="grid_4'; } ?>">
    		<h2><a href="<?php the_permalink() ?>"
    rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <?php the_title(); ?>
    </a></h2>
        </div><!-- end of Entry Content -->
        </div><!-- end of grid_4 -->
      <?php endwhile; ?>
       <?php rewind_posts(); ?>

    The error I'm getting is in Dremweaver suggesting that my syntax at the end of my custom loop in functions.php there is a syntax error. Any thoughts greatly appreciated!

    Posted 7 years ago #
  2. you do not appear to be closing

    <div id="<?php if ($counter == 1) { echo'newsone" class="grid_4'; } ?>">

    after </div><!-- end of Entry Content -->

    Posted 7 years ago #
  3. proto
    Member

    Thanks Helga,

    Excuse me being totally silly but do I need to close down the statement with and <?php endwhile: else ?>

    I'm at the point where it's hard to see the wood for the trees!! :)

    (*clears desk preparing for facepalmage*)

    Posted 7 years ago #
  4. <div id="rowTwo" class="grid_12"></div>
        <?php query_posts('category_name=news&posts_per_page=2');?>
    <?php while (have_posts()) : the_post(); ?>
    <?php $counter++; ?>
     <div id="<?php if ($counter == 1) { echo'newsone" class="grid_4'; } ?>">
    <?php thematic_postheader();?>
    <div class="entry-content">
    <?php
          if (has_post_thumbnail()) {
            the_post_thumbnail('home_pic');
          } ?>
    		<?php the_excerpt(); ?>
    
           <a href="<?php the_permalink(); ?>" class="more">
    <?php echo more_text() ?></a>
        </div><!-- end of Entry Content -->
        </div><!-- end of #newsone.grid_4 -->
      <?php endwhile; ?>
       <?php else : ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php $counter++; ?>
     <div id="<?php if ($counter == 2) { echo'newstwo" class="grid_4'; } ?>">
    		<h2><a href="<?php the_permalink() ?>"
    rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <?php the_title(); ?>
    </a></h2>
        </div><!-- end of Entry Content -->
        </div><!-- end of grid_4 -->
      <?php endwhile; ?>
       <?php rewind_posts(); ?>

    i "think" you were missing : </div><!-- end of #newsone.grid_4 --> but i'm not sure either. it is indeed getting difficult to see what is going on w/ all the code. why do you have two while loop?

    what i always suggest is that you strip it down to the bare minimums to get it working.

    <?php
    $counter = 0;
    query_posts('category_name=news&posts_per_page=2');
    while (have_posts()) : the_post();
    $counter++;
    if ($counter == 1):
    ?>
    
    BACON!!!
    
    <?php else : ?>
    
    everything else
    
    <?php
    endif;
    endwhile;
    rewind_posts();
    ?>

    also untested, but that should be a start

    Posted 7 years ago #
  5. proto
    Member

    Thanks Helga,

    I think you're right keeping it simple is always preferable! In a nutshell I want to output the newest full post exerpt and then the second newest post to be just a title. If someone knows how to do this in a loop please share and hopefully this will be useful to others who come aferwards too!

    Posted 7 years ago #
  6. turns out i made some typos and forgot an endif (i've edited it so it should work now), but my above snippet will do exactly what you want... you just need to flesh it out w/ the_title(), the_post_thumbnail() and anything else you'd rather have than bacon

    Posted 7 years ago #
  7. proto
    Member

    Thank you Helga,

    I'm trying to think of a new superlative that hasn't been used to thank you (this could take some time!!)

    In the meantime THANK YOU!

    Posted 7 years ago #
  8. also if you are doing your news category that way can't you just use the overrides.... don't see why you are using a query?

    childtheme_override_category_loop(){
    if(is_category('news')){
    $counter = 0;
    while (have_posts()) : the_post();
    $counter++;
    if ($counter == 1):
    ?>
    
    BACON!!!
    
    <?php else : ?>
    
    everything else
    
    <?php
    endif;
    endwhile;
    } else {
    thematic_category_loop()
    }

    i await your new superlatives.... maybe i will put them on my website. ;)

    Posted 7 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.