Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Wordpress: Conflicting code for comments

  • 15-09-2010 09:40PM
    #1
    Registered Users, Registered Users 2 Posts: 3,057 ✭✭✭


    Hey Guys,
    My head has been aching for a wee while and I've finally narrowed down the problem to a few lines. If you could help I'd REALLLLY appreciate it!

    I'm building a theme from scratch and everything is working bar showing the comments on the single.php page.

    I am calling
    <?php comments_template(); ?>

    but it seems to conflict with this bit of code that is in bold (which calls related posts just above the comments)
    <?php
    $tags = wp_get_post_tags($post->ID);
    if ($tags) {
    $tag_ids = array();
    foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;

    $args=array(
    'tag__in' => $tag_ids,
    'post__not_in' => array($post->ID),
    'showposts'=>5, // Number of related posts that will be shown.
    'caller_get_posts'=>1
    );
    $my_query = new wp_query($args);
    if( $my_query->have_posts() ) {
    echo '<ul>';
    while ($my_query->have_posts()) {
    $my_query->the_post();
    ?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    <?php
    }
    echo '</ul>';

    }
    }
    ?>

    Anyone have any ideas?

    Thanks,
    Kyle


Comments

  • Closed Accounts Posts: 19 jimkennedy


    Hey Kyle,

    Did you try turning it off and back on again? <smiley face icon>

    Jim.


  • Registered Users, Registered Users 2 Posts: 3,057 ✭✭✭kjt


    Just tried that Jim, didn't work :-/


  • Registered Users, Registered Users 2 Posts: 3,057 ✭✭✭kjt


    Got it sorted. In case anybody has the same problem, just add this code below the custom loop.
    wp_reset_query();

    Kyle


Advertisement