WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Title tag for 6 pages all the same? (6 posts)

  1. bencharity
    Member
    Posted 4 years ago #

    Ok what am I missing?? I've been exploring more with template tweaks so I'm sure it's something simple and I'll kick myself...

    I have my site (http://benjamincharity.com) split in two: Personal and Freelance.

    I am using these calls in my title tag (this code is identical in my personal header (header.php) and my freelance header (header-freelance.php):

    <title><?php wp_title(); ?> | <?php bloginfo('name'); ?></title>

    Yet somehow while all the titles are correct on the personal side, every page on the freelance side is displayed as "Support | Benjamin Charity".

    I have a blog category called 'Support' but I can't figure out how it could be affecting me.

    I'm looking forward to learning something new! Thanks in advance to any kind souls!
    Benjamin

  2. bencharity
    Member
    Posted 4 years ago #

    bump

  3. bencharity
    Member
    Posted 4 years ago #

    No clues? Anyone?

  4. bencharity
    Member
    Posted 4 years ago #

    bump

  5. bencharity
    Member
    Posted 4 years ago #

    Ok, I've narrowed it down to this piece of code.

    <div id="recentPosts">
    	<h3>Recent Posts</h3>
    
    <?php
    query_posts('showposts=2&cat=7');
    while(have_posts()) : the_post();
    ?>
    
    	<div class="similarSingle">
    		<h5><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h5>
    
    		<?php the_excerpt(); ?>
    
    	</div>  <!-- end .similarSingle -->
    
    <?php endwhile; ?>
    </div>  <!-- end #recentPosts -->

    Specifically I think it is this piece:

    while(have_posts()) : the_post();

    When I remove the above code from the page, my title appears correctly. Any way around this?

  6. bencharity
    Member
    Posted 4 years ago #

    Ok I have found a fix for this by adding <?php wp_reset_query(); ?> after the trouble code.

    Example:

    <?php
    query_posts('showposts=2&cat=7');
    while(have_posts()) : the_post();
    ?>
    
    <h5><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h5>
    
    	<?php the_excerpt(); ?>
    
    <?php endwhile; ?>

    Should be:

    <?php
    query_posts('showposts=2&cat=7');
    while(have_posts()) : the_post();
    ?>
    
    <h5><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h5>
    
    	<?php the_excerpt(); ?>
    
    <?php endwhile; ?>
    <?php wp_reset_query(); ?>

    This took forever for me (a novice) to figure out, so hopefully this helps someone else. Also, if anyone can explain exactly why I need to manually reset the query, I'd love to know.

Topic Closed

This topic has been closed to new replies.

About this Topic