WordPress.org

Ready to get started?Download WordPress

Forums

comment template problem (24 posts)

  1. ronaldb73
    Member
    Posted 4 years ago #

    I have the following problem:
    In general I let people react to any post on the site and all works fine. But with some posts I want to disable the comment option. Problem is that whenever I uncheck the comment option and save the post, the sidebar drops below the post.

    I've counted all the div's and /div's and that's not the problem. Anyone have any idea what could cause this?
    OR
    Can anyone tell me how to NOT load the comments template in some categories?

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    Anyone have any idea what could cause this?

    A link to a page demonstrating the problem would help. It's probably a CSS or markup issue.

  3. ronaldb73
    Member
    Posted 4 years ago #

    Ok, the following is a post with comments enabled (and therefor no problems):
    http://www.denhelderactueel.nl/14/09/2009/zeestad-minder-succesvol-dan-gehoopt/

    The following is a post with comments disabled:
    http://www.denhelderactueel.nl/29/06/2008/de-boer-wint-ledentoernooi/

    Hope you can help.

  4. esmi
    Forum Moderator
    Posted 4 years ago #

    You're missing the closing </div> for #contentleft when comments aren't enabled - which means that your right sidebar is being rendered inside your #contentleft instead of to the right of it.

    You need to take a closer look at single.php.

  5. ronaldb73
    Member
    Posted 4 years ago #

    the single.php shows exactly 20 times <div> and 20 times </div>
    should I post the code here?

  6. esmi
    Forum Moderator
    Posted 4 years ago #

    Use the WordPress pastebin and then post the pastebin url here.

  7. ronaldb73
    Member
    Posted 4 years ago #

  8. esmi
    Forum Moderator
    Posted 4 years ago #

    Have you looked at comments.php? Do the opening and closing divs match in that file? I think the comments.php is supplying the closing </div> for #contentleft. So no comments - no closing </div>

  9. ronaldb73
    Member
    Posted 4 years ago #

    Looked at comments, exactlty 18 times <div> and 18 times </div>
    see: http://wordpress.pastebin.ca/1567993

  10. ronaldb73
    Member
    Posted 4 years ago #

    anyone have any idea?

  11. Mark / t31os
    Moderator
    Posted 4 years ago #

    Well then leaves the header, footer and sidebar files as possible culprits..

    Create an empty php document, paste the code in from the header, followed by the code from the footer, now look at the elements...

    Those 2 files together should form a layout of complete elements, what would usually be sat between them makes no difference..

  12. ronaldb73
    Member
    Posted 4 years ago #

    Well, when I do that (take the code of header and footer and copy/paste it in a new file) I come to 13 times <div> and 13 times </div>.

    See: http://wordpress.pastebin.ca/1568534

    so, what else could be wrong?

  13. Mark / t31os
    Moderator
    Posted 4 years ago #

    Then it'll be whatever sits between those... (i think)..

    page.php if it's a page
    single.php if it's a single post

    etc..

  14. ronaldb73
    Member
    Posted 4 years ago #

    we started out with looking at the single.php and with page.php it's not a problem, cause that file doens't call the comments template.

  15. Mark / t31os
    Moderator
    Posted 4 years ago #

    Do you have a custom callback for comments in your functions file?

  16. ronaldb73
    Member
    Posted 4 years ago #

    what is a callback? where do I look for?

  17. Mark / t31os
    Moderator
    Posted 4 years ago #

    The functions.php file for your theme.

  18. ronaldb73
    Member
    Posted 4 years ago #

    i don't think it does anything with the comments form, only with the comments in feed and sidebar.

    See functions.php: http://wordpress.pastebin.ca/1568760

  19. Mark / t31os
    Moderator
    Posted 4 years ago #

    Try updadting these lines in the single.php

    <ul>
    				<?php if ( in_category('62') ) {
    		include(TEMPLATEPATH . '/sidebar-deriepel.php');
    		}
    		else if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else : ?>
    			<?php include (TEMPLATEPATH . '/sidebar-2.php'); ?>
    
    		<?php endif; ?>
    		</ul>
    	</div>
    </div>

    to..

    <ul>
    		<?php
    		if ( in_category('62') ) {
    			include(TEMPLATEPATH . '/sidebar-deriepel.php');
    		}
    		else {
    			if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else : include (TEMPLATEPATH . '/sidebar-2.php'); endif;
    		}
    		?>
    		</ul>
    	</div>
    </div>

    Looks like there were some minor mistakes there, see if that helps..

  20. ronaldb73
    Member
    Posted 4 years ago #

    Sorry, it doesn't work, doesnt change a thing (but doesn't do any harm either).

  21. ronaldb73
    Member
    Posted 4 years ago #

    In page.php I removed the complete comments form and that doesn't give any problems. Isn't there a way to use single.php for all posts, but single2.php for all posts that belong to a certain category? Then I can remove the comments form in single2.php (like in page.php) and hopefully the problem is solved then?

    Could this work and if yes, how do I do this?

  22. Mark / t31os
    Moderator
    Posted 4 years ago #

    No need for that just wrap the comments_template call in a condition..

    <?php if(!in_category('XX')) { comments_template(); } ?>

    So if not ! in category XX, where XX is the ID or category name/slug.

    http://codex.wordpress.org/Function_Reference/in_category

  23. ronaldb73
    Member
    Posted 4 years ago #

    there is only one category where i don't want comments enabled, so let's say this is category id 63. What must the code look like then? In single.php the only call to comments is:
    <?php comments_template(); ?>

  24. ronaldb73
    Member
    Posted 4 years ago #

    I've found a different solution.

    I've added the following code to my themes functions.php:
    add_filter('single_template', create_function('$t', 'foreach( (array) get_the_category() as $cat ) { if ( file_exists(TEMPLATEPATH . "/single-{$cat->term_id}.php") ) return TEMPLATEPATH . "/single-{$cat->term_id}.php"; } return $t;' ));

    now when i create a single-xx.php (where xx is the ID of the category) all posts in this category use the single-xx.php instead of single.php.

Topic Closed

This topic has been closed to new replies.

About this Topic