WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Missing tags on first post (3 posts)

  1. CQSite
    Member
    Posted 5 years ago #

    Tags are not showing up on my first post, but are showing up on subsequent posts, and the individual post pages.
    cinnamonquill.com

    I've read the article here: http://return-true.com/2008/12/using-wp_query-to-make-custom-queries-within-wordpress-templates/ and tried to implement what it said, but I started getting an "endwhile" error.

    I appreciate the help, thank you.

    Jenn

    <?php get_header(); ?>
    
    <div id="entry">
    
            <div class="recent">
            <?php $my_query = new WP_Query('showposts=1');
            while ($my_query->have_posts()) : $my_query->the_post();
            $do_not_duplicate = $post->ID; ?>
    
            <div class="post new" id="post-<?php the_ID(); ?>">
    
                <div class="info">
                          <div class="latest">
                        <h3 class="title"></h3>
                        <div class="date">Posted on <?php the_time('M d Y'); ?> by <?php the_author() ?></div>
                        </div><!--latest-->
    
                        <br clear="all" />
    
                </div><!--info-->
    
           		<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>       
    
            	<div class="content"><?php the_content('Read more ยป'); ?></div>
    
                <div class="meta">
    
                  <div class="tags"><?php the_tags('', ', ', '<br />'); ?></div>
    
                        <div class="cats"><?php the_category(', ') ?>
                        <br />
                           <div class="comcount">
                        <?php comments_popup_link('0 Comments', '1 Comment', '% Comments'); ?>
                        </br>
                        </div></div>
                </div><!--meta-->
    
            </div><!--post-->
            <?php endwhile; ?>
            </div><!--recent-->
            <div class="recentbottom"><!-- --></div>
    
    		<?php if (have_posts()) : while (have_posts()) : the_post();
            if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
    
            <div class="post recent" id="post-<?php the_ID(); ?>">
    
             	<div class="info2">
                        <div class="latest">
                        <div class="date">Posted on <?php the_time('M d Y'); ?> by <?php the_author() ?></div>
                        </div><!--latest-->
                      <!--comcount-->
                        <br clear="all" />
                </div><!--info-->
    
            <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>       
    
            <div class="content"><?php the_content('', TRUE, '', 40); ?></div>
    
            <div class="meta">
    
                    <div class="tags"><?php the_tags('', ', ', '<br />'); ?></div>
        <div class="cats"><?php the_category(', ') ?>
        <br />
      <div class="comcount">
                        <?php comments_popup_link('0 Comments', '1 Comment', '% Comments'); ?>
                        </br>
                        </div></div>
    
            </div><!--meta-->
    
            </div><!--post-->
            <div class="recentbottom"><!-- --></div>
    		<?php endwhile; ?>
    
            <div class="alignleft"><?php next_posts_link('Older Entries') ?></div>
            <div class="alignright"><?php previous_posts_link('Newer Entries') ?></div>
            <br clear="all" />
    
    		<?php else : ?>
    		<?php endif; ?>
    
    </div><!--entry-->
    <div id="angelbg"><!-- --></div>
    <?php include (TEMPLATEPATH . '/sidebar.php'); ?>
    <?php get_footer(); ?>
  2. MichaelH
    Member
    Posted 5 years ago #

    In your first loop, change:

    <div class="meta">
    <div class="tags"><?php the_tags('', ', ', ''); ?></div>

    to:

    <div class="meta">
    <?php
    //this is necessary to show the tags
    global $wp_query;
    $wp_query->in_the_loop = true;
    ?>
    <div class="tags"><?php the_tags('', ', ', ''); ?></div>
  3. CQSite
    Member
    Posted 5 years ago #

    Perfect. Thank you very much!

Topic Closed

This topic has been closed to new replies.

About this Topic