• Hello,
    I found this code on a website which have to query titles from tags, which I’m using for related posts. This code simply list all post title links under every post page.

    The problem is query never ends and mysql connections limit increases. What’s wrong in this code? Can anyone fix this for me?

    Please help..

    <!-- related posts START -->
    <h3>You may also like...</h3>
    <ul>
    <?php
    $posttags = get_the_tags();
    $test = '';
    $sep = '';
    if ($posttags) {
        foreach($posttags as $tag) {
            $test .= $sep . $tag->name;
            $sep = ",";
        }
    }
    query_posts('tag=' .$test . '&showposts=-1&orderby=title&order=ASC'); while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; wp_reset_query(); ?>
    </ul>
    <!-- related posts END -->
  • The topic ‘Querying from tags problem’ is closed to new replies.