Forums

Tabbed posts (3 posts)

  1. jessn
    Member
    Posted 2 years ago #

    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!!

  2. alchymyth
    The Sweeper
    Posted 2 years ago #

    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.

  3. jessn
    Member
    Posted 2 years ago #

    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; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic