Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying the Wordpress 'Comments Template' outside the 'loop'

So I'm building a wordpress theme, and I need the comments to come down in a dropdown from each post on the homepage. Bullshit you have to click on the post to see the comments! It worked really well, when there was only one post. It worked with only one post because I was displaying the comments template OUTSIDE the loop. But with multiple posts, the comments template must be inside the loop, however, when you put the comments template reference in the loop it doesn't fire, meaning the template isn't displayed!

How can I get the comments template to display in the loop so it will appear on each post on the homepage and I can set it up as a dropdown menu?

Here's the site I'm implementing it on: http://thenozzle.net/ You can see it, or rather, not see it happening if you click on 'Show # Comments Here'. Simple php stuff, but I can't figure out why when the comments template reference is palce din th eloop, is doesn't fire.

Here's the reference and code:

<div id="dropdowncomments">
        <?php comments_template(); ?>
</div>

Like I said, dropdown comments is hidden, and when you click on it, it appears, but comments template isn't loading inside loop.php so, no good.

Any help?

like image 316
alt Avatar asked Jun 17 '11 10:06

alt


People also ask

How do I add a custom comment in WordPress?

Adding Custom Comment Fields in WordPress Click on the Comment Fields tab. The plugin offers four options to add to your comment fields. These include select box, radio input, checkbox, and the traditional text input. Click and drag the option you want into the box on the right.

How do I style comments in WordPress?

Style WordPress Comments Using SeedProd Theme Builder. Change WordPress Comments with Default CSS Classes. Adding Social Login to WordPress Comment Form. Adding Comment Policy Text in WordPress Comment Form.


1 Answers

It is easy (I hope I understood you correctly). Just after the the_content() call, setup the $withcomments variable (global) and call comments_template():

the_content();
global $withcomments;
$withcomments = 1;
comments_template( 'comments.php', true );
like image 116
AJJ Avatar answered Nov 15 '22 00:11

AJJ