WordPress.org

Ready to get started?Download WordPress

Forums

Stuck tags in template (12 posts)

  1. WayneSmallman
    Member
    Posted 5 years ago #

    Hi guys, for some reason, the tags in all my articles are stuck.

    When I say stuck, they're showing the tags for one particular article in all other articles.

    For instance, if you go to my hardening economy article and scroll down, you'll see the tags: "learning, Organic Knowledge" but they're only for the Organic Knowledge article.

    I've swapped code around from my other blog, but no avail.

    The code for the tags is: the_tags( '<p>Tags: ', ', ', '</p>');

    Any ideas would great!

  2. MichaelH
    Member
    Posted 5 years ago #

    Might paste your index.php at a pastebin such as http://wordpress.pastebin.com/ and report the link back here.

  3. WayneSmallman
    Member
    Posted 5 years ago #

    Hi Michael, it's not index.php, it's single.php.

    As requested, here's the code from Paste Bin.

    Thanks!

  4. MichaelH
    Member
    Posted 5 years ago #

    You have multiple loops in that code so assuming you want both you should use the rewind_posts template tag.

  5. WayneSmallman
    Member
    Posted 5 years ago #

    You mean the one at the top and the main one for the content?

    I use the same thing on Blah without any problems and there's no rewind template tag being used.

    I've removed the loop from the top of the single.php file and it's not changed anything.

  6. MichaelH
    Member
    Posted 5 years ago #

    Wonder if something in your sidebar.php is resetting your post loop?

    If you change to the WordPress Default theme do you see the correct tags when viewing a single post?

  7. WayneSmallman
    Member
    Posted 5 years ago #

    Yes, changing the template does make the tags load properly.

    Here's the code for sidebar.php on Paste Bin

    BTW, thanks for your help so far! Much appreciated...

  8. MichaelH
    Member
    Posted 5 years ago #

    See if this works in your sidebar.php: (didn't test this)

    replace

    <?php global $post; $myposts = get_posts('numberposts=5'); foreach($myposts as $post): ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>

    with

    <?php $recent= new WP_Query('numberposts=5');
    while ($recent->have_posts()) : $recent->the_post(); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
  9. cpoteet
    Member
    Posted 5 years ago #

    Wayne what does the oil_am_Display(); function do? I don't see anything weird in the sidebar file. What are the two loops actually accomplishing?

  10. WayneSmallman
    Member
    Posted 5 years ago #

    Hi Michael, the tags are still stuck, but this time they're from a much earlier article. Also, it ignores the number of articles to be viewed in the query.

    So the problem is clearly related to the Recent Articles, because when I take the code out, all is fine.

    Hi Chris! That's a function my Ask Me! Plugin uses.

    But that's been disabled, so it wouldn't have done anything.

    So right now, I'm using:

    <?php foreach(get_posts('numberposts=5') as $post): ?>
    li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <php endforeach; ?>

    I just don't know enough about WordPress to figure this one out, despite all my PHP know-how...

  11. MichaelH
    Member
    Posted 5 years ago #

    Sorry, the numberposts=5 should be showposts=5. But you might want to try a new WP_query on your other loops.

  12. WayneSmallman
    Member
    Posted 5 years ago #

    OK, doesn't look like this is working.

    I might have to scrap the recent articles code, or find some new code.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags