• Quick question for you guys: on the home page of my WordPress site I want to have a block with some tabs across the top, and each tab displays a different post, queried by a particular tag. I want the tab names to echo the category that that post is in. I’m kind of close, but not quite as it’s not really working. Can anyone see what I’m doing wrong?

    <div class="tabber">
    <?php
    		$i = 1;
    		while($i < 5) {
    	?>
    	<div class="tabbertab">
    
     <h2><?php $featcat = the_category('tabber_'.$i); echo $featcat; ?></h2>
    		<?php query_posts('tag=home'); ?>
    <?php while (have_posts()) : the_post(); ?>
    		<h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    		<?php the_content(); ?>
    		<?php endwhile; ?>
    
            <div class="clear"></div>
    	</div>
    	 <?php
    			$i++;
    		}
    	?>
    </div>

    Thanks so much!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • tag? category? what do you really want?

    at them moment, you are listing a category name on top of the tab; then you query the same tag ‘home’ all the time.

    Thread Starter Jess

    (@jessn)

    Yep. The tab echoes the name of the category that the post is in. I got it figured out:

    <?php query_posts('tag=home'); ?>
    <?php while (have_posts()) : the_post(); ?>
      <?php $category = get_the_category();  ?>
    
      <div class="tabbertab">
        <h2><? echo $category[0]->cat_name; ?></h2>
    
        <?php the_excerpt(); ?>
      </div>
    
    <?php endwhile; ?>
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Tabbed posts’ is closed to new replies.