• Hey guys.

    here’s my setup:

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <p id="small"><small>Written by <?php the_author() ?></small></p>
    <?php the_content(''); ?>
    <?php endwhile; endif; ?>

    that pulls in the content of the article. below that, in a seperate div, i have 3 other queries:

    1. Categories
    2. Recent comments
    3. and an ‘other articles’ query

    the other articles looks like this:
    <?php query_posts('cat=14,13,8,2,6,4,3,12,5,10,7,9'); ?>
    <?php $posts = get_posts('numberposts=13&offset=2'); foreach ($posts as $post) : start_wp(); ?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>

    thats all in a panel on the left.

    then on the right, i have the comments in a seperate div, horizontally in line with the article itself.

    i’m pulling this in with the standard comments_template function.

    however the comments that are being pulled in are not of the article.. they’re pulling in from a different article. every article i click on, displays the comments from another specific article.

    i’m thinking there’s an error in one of the preceding queries, but i’m not experienced enough to know where…

    i hope someone can assist… or perhaps recommened a different way of doing the above..

    thank you

Viewing 6 replies - 1 through 6 (of 6 total)
  • it is probably caused by calling the comment_template outside the loop ..

    Thread Starter Mark Bloomfield

    (@yellowllama)

    thanks silkjaer…altho i’m not 100% sure thats the problem because in other working sites i have, i have the comments running outside the loop… (i think).. in a seperate div…

    is there no way to manually tweak that comments_template function to specify which article’s comments it displays, relative to the page its on?

    If you run comments outside the loop, the comments might show up correctly, but visitors wont be able to post a comment …

    Conceptually,

    -- START LOOP 1 --
    display content
    -- END LOOP 1 --

    SAVE QUERY for LOOP 1

    -- START LOOP 2 --
    do something
    -- END LOOP 2 --

    -- START LOOP 3 --
    do something
    -- END LOOP 3 --

    RESTORE and RESET QUERY for LOOP 1
    -- START LOOP 1 --
    display comment
    -- END LOOP 1 --

    Thread Starter Mark Bloomfield

    (@yellowllama)

    alphaoide that sounds like a winner… how do i restore & reset the query tho?

    To save a query…
    $temp_query = $wp_query;

    Then to restore and reset it…
    $wp_query = $temp_query;
    rewind_posts();

    P.S. It’ll be different code if you have PHP 5

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Comments in seperate div not working’ is closed to new replies.