multiple comments.php files for each single.php
-
I want to load a 2nd and 3rd comments.php file.
Here are my steps:
First i duplicate comments.php into -> comments1.php and comments2.phpSo now i have 3 different files only with the same code inside.
And now when i start loading them i want to see which and if a file is getting loaded.So thats why i changed on each comments.php template (file) the heading 3 title like this:
comments.php -> <h3 id=”comments-title000″>
comments1.php -> <h3 id=”comments-title111″>
comments2.php -> <h3 id=”comments-title222″>Now i try to include them on a single.php template first i take the comments2.php just to check if it works.
I add this:
Delete this (old)<?php comments_template( '', true ); ?>I tried all those options! (new)
<?php include ( '/comments2.php ); ?> <?php include ( 'comments2.php ); ?> <?php comments_template( '/comments2.php', true ); ?> <?php comments_template( 'comments2.php', true ); ?> <?php comments_template( '/comments2.php' ); ?> <?php comments_template( 'comments2.php' ); ?>Nothing worked. sometimes it broke my template and i got a white screen, the other time i only got a comment_form but none comments and last i got a great looking brand new comments section but it wasn’t loading by the comment2.php or the comments.php but it came from this path.
wp-includes > theme-compat > comments.php
What is going wrong on my site?
I have been searching for a solution for a long time but i can’t find anything that works.Look at this:
http://codex.wordpress.org/Function_Reference/comments_template
Quote from that page:On some occasions you may want display your comments differently within your Theme. For this you would build an alternate file (ex. short-comments.php) and call it as follows:
<?php comments_template( '/short-comments.php' ); ?>Thats what i’m doing…
But still my templates will not get loaded.Some other quotes on that page:
Loads the comment template. For use in single post and Page displays.
Maybe it’s because i’m using a few different single.php files also. could that be a problem? I also duplicated my single.php a few times didn’t change lots of code most of the time it was just some different classes for css.
I have include this inside my single.php
<?php $post = $wp_query->post; if (in_category('1')) { include(TEMPLATEPATH.'/single-web.php'); }elseif (in_category('18')) { include(TEMPLATEPATH.'/single-web.php'); }elseif (in_category('2')) { include(TEMPLATEPATH.'/single-print.php'); }elseif (in_category('19')) { include(TEMPLATEPATH.'/single-newsfeed.php'); }else { include(TEMPLATEPATH.'/single-default.php'); } ?>This works great i have different single templates for each category.
I really would love to know why my site is not loading a different comments.php template.
Maybe somebody who knows the WordPress people very good can clear my mind and tell me why do they go from a single.php template inside the theme folder to a comment-template.php file outside my theme folder and inside the wp-includes folder (core files) and from this comment-template.php file they go straight back inside my theme folder to the file comments.php ???
I don’t get the logic but i’am not a coding person so i don’t wanna look the smart-guy here but i think calling 3 different template-files for loading comments into a page is lots of traffic and you can mess things up very easy. (comment-template.php, comments.php and functions.php)I found somebody with the same problem as i have but i don’t know what the last person is saying in this topic.
Yeah a little bit i can understand..
http://wordpress.org/support/topic/2-comments-templates-1?replies=3
I think he is pointing to something of the same i did with the the single.php template.
something like:
If comments are in category (..) go to …template and if not go to default. but how do i use this code for comments and comment-templates?Thanks for your time.
The topic ‘multiple comments.php files for each single.php’ is closed to new replies.