• I’m trying to update a theme for a site I’m designing to display tags with the 2.3 update. I have pasted <?php the_tags('Tags: ', ', ', ''); ?> into the template at the appropriate place, but no tags show up. However, on the single post view, they show up. I’m guessing that the reason they aren’t showing up is that I’m running The Loop twice, and the tags are supposed to display in the second instance of The Loop. Is there any way to make them display?

    Here’s the blog page: https://www.justgospel.net/blog/ The template tag <?php the_tags('Tags: ', ', ', ''); ?> is between the two pipes, after the date, in the postmetadata. If you click on the title you’ll see that they display properly there.

    Thanks for any help!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter hesed2

    (@hesed2)

    I’m sorry to say this, I don’t want to come across as ungrateful, but could someone tell me what I have to do to get help?

    Some code listing would help us figure what you are doing wrong. And also why are you running the loop twice?

    Thread Starter hesed2

    (@hesed2)

    Thanks for responding. I’m running the loop twice so that I can use WP in more of a CMS fashion, creating pages that display post in a particular category. So each page only displays post from the corresponding category.

    Here is the code for the page running the blog:

    <?php/*Template Name: Blog Template*/?>
    <?php get_header(); ?>
    
    <div id="main">
    	<div id="content">
    
            <!-- The Loop starts here... -->
            <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                <div id="post-<?php the_ID(); ?>">
                <h2><?php the_title(); ?></h2>
                <div class="entry">
                    <?php the_content(); ?>
                </div>
                <p class="postmetadata"><?php edit_post_link('Edit','',''); ?></p></div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		<?php include (TEMPLATEPATH . "/searchform.php"); ?>
    
            <?php endif; ?>
    
            <?php $my_query = new WP_Query('category_name=' . get_query_var('name') . '&showposts=10'); ?><!-- Rewinds The Loop so we can call more posts -->
    			<?php while ($my_query->have_posts()) : $my_query->the_post(); ?><!-- Restricts posts to those matching the page category -->
    
    			<div class="post" id="post-<?php the_ID(); ?>">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    				<p class="postmetadata">Posted by <?php the_author(); ?> on <?php the_time('D, M j, Y'); ?></p>
    
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    
    				<p class="postmetadata">Posted by <?php the_author(); ?> on <?php the_time('D, M j, Y'); ?> | <?php the_tags('Tags: ', ', ', ''); ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <a href="<?php the_permalink() ?>#comments" rel="bookmark" title="Comment on <?php the_title(); ?>"><?php comments_number('No Comments »', '1 Comment »', '% Comments »'); ?></a></p>
    			</div>
    
    		<?php endwhile; ?>
    
            <!-- The Loop ends here -->
    
    	</div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    Have you tried inserting the tag code in your first loop to see if it works? Lets try to breakdown to where the problem is occurring

    Give this a try on a test page and see if it helps: [Just change the cat ID to suit]

    <?php $posts = get_posts( "category=1&numberposts=1" ); ?>
    <?php if( $posts ) : ?>
    <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2><h3><?php the_category(',') ?><?php edit_post_link('...', '', ''); ?></h3>
    <?php the_content(__('more')); ?>
    <?php the_tags(); ?>
    <?php endforeach; ?> <?php endif; ?>

    and again

    <?php $posts = get_posts( "category=2&numberposts=1" ); ?>
    <?php if( $posts ) : ?>
    <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2><h3><?php the_category(',') ?><?php edit_post_link('...', '', ''); ?></h3>
    <?php the_content(__('more')); ?>
    <?php the_tags(); ?>
    <?php endforeach; ?> <?php endif; ?>

    I haven’t tried it with the Tag addition, but I can no reason why it woudn’t work.

    Thread Starter hesed2

    (@hesed2)

    The problem with putting it in The Loop the first time is that the first loop pulls the info for the Page, and there’s no way to tag pages, so it wouldn’t display any info anyway.

    Shadow, that just doesn’t work.

    Thread Starter hesed2

    (@hesed2)

    I guess I should assume that this is a bug, then?

    The only explanation for why the tags are not being displayed is that the call is in the second instance of The Loop, and yet other template tags, such as `the_excerpt’ that must be within The Loop display fine.

    Could someone tell me how to report this as a bug?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Help with tags’ is closed to new replies.