WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Tags won't show in complex page template (2 posts)

  1. Erin B.
    Member
    Posted 4 years ago #

    I have a page in which the page content appears at top, followed by a category query which returns the one most recent post and then the titles of all posts in that category. I want to show the tags in the posts and below the titles, but the_tags() is not working for some reason.

    here's my code

    <?php
    
    /*
    
    Template Name: Lessons and Activities Page
    
    */
    
    ?>
    
    <?php get_header(); ?>
    
    <?php get_sidebar(); ?>
    
    <div id="content">
    
        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<div class="post" id="post-<?php the_ID(); ?>">
    
    		<h2><?php the_title(); ?></h2>
    
    		<div class="entry">
    
    		<?php the_content('<p>Continue reading &raquo;</p>'); ?>
    
    	 <?php endwhile; endif; ?>
    
    <!--get latest Lessons and Activities post-->
    
    <h3>Recently Added </h3>
    
      <?php $my_query = new WP_Query('category_name=lessons&showposts=1');
    
      while ($my_query->have_posts()) : $my_query->the_post();?>
    
    	<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    
        <?php the_title(); ?></a></h2><small><?php the_time('F jS, Y') ?> <?php the_tags('| Topic: ', ', ', '.') ?></small>
    
    			<?php echo the_content(); ?> 
    
    				  <?php endwhile; ?>
    
    <!--get all archived Lessons and Activities posts-->
    
    <h3>All Lessons and Activities</h3>
    
      <?php $my_query = new WP_Query('category_name=lessons');
    
      while ($my_query->have_posts()) : $my_query->the_post();
    
      $do_not_duplicate = $post->ID; ?>
    
        <!-- Do stuff... -->
    
    	<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    
        <?php the_title(); ?></a></h3><small><?php the_time('F jS, Y') ?> <?php the_tags('| Topic: ', ', ', '.') ?></small>
    
      <?php endwhile; ?>
    
    		<br />
    
    		</div>
    
    		<h2>Submit a Lesson Plan or Activity</h2>
    
    <p>Please use the form below to submit a new lesson plan or teaching activity. Your material will be reviewed by Ohio Civil War 150 staff and added to the list as soon as possible.</p>
    
    		<?php echo insert_cform('Lesson Plan Submission');?>
    
    	</div>
    
    </div>
    
    <?php get_footer(); ?>
  2. Erin B.
    Member
    Posted 4 years ago #

    nevermind... i just needed to clean up my secondary loops. see below. As an aside, the comments were also not working before, so if your comments don't appear in a template, you should try fixing the loop as such...

    <?php
    
    /*
    
    Template Name: Lessons and Activities Page
    
    */
    
    ?>
    
    <?php get_header(); ?>
    
    <?php get_sidebar(); ?>
    
    <div id="content">
    
        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<div class="post" id="post-<?php the_ID(); ?>">
    
    		<h2><?php the_title(); ?></h2>
    
    		<div class="entry">
    
    		<?php the_content('<p>Continue reading &raquo;</p>'); ?>
    
    	 <?php endwhile; endif; ?>
    
    <!--get latest Lessons and Activities post-->
    
    <h3>Recently Added </h3>
    
      <?php query_posts('category_name=lessons&showposts=1');?>
    
      <?php while (have_posts()) : the_post();?>
    
    	<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    
        <?php the_title(); ?></a></h2><small><?php the_time('F jS, Y') ?> <?php the_tags('| Topic: ', ', ', ' | ') ?><?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></small>
    
    			<?php echo the_content(); ?> 
    
    				  <?php endwhile; ?>
    
    <!--get all archived Lessons and Activities posts-->
    
    <h3>All Lessons and Activities</h3>
    
      <?php query_posts('category_name=lessons');?>
    
      <?php while (have_posts()) : the_post();?>
    
    	<div><h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    
        <?php the_title(); ?></a></h3><small><?php the_tags('Topic: ', ', ', ' | ') ?><?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></small></div><br />
    
      <?php endwhile; ?>
    
    		<br /><br />
    
    		</div>
    
    		<h2>Submit a Lesson Plan or Activity</h2>
    
    <p>Please use the form below to submit a new lesson plan or teaching activity. Your material will be reviewed by Ohio Civil War 150 staff and added to the list as soon as possible.</p>
    
    		<?php echo insert_cform('Lesson Plan Submission');?>
    
    	</div>
    
    </div>
    
    <?php get_footer(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic