Viewing 8 replies - 1 through 8 (of 8 total)
  • Most themes use the comments_template() function for standardization, and that looks for comments.php in the root of the theme folder.

    Thread Starter Fawzi

    (@fauzurrahman15)

    yes. i change comments_template() with all code from comments.php to single.php but it doesn’t work

    Moderator bcworkz

    (@bcworkz)

    You may have accidentally introduced a syntax error. Try defining WP_DEBUG as true in wp-config.php so PHP can tell you what errors it encountered right on the page you’re viewing.

    Thread Starter Fawzi

    (@fauzurrahman15)

    it says “Undefined variable: comments” what to do?

    Moderator bcworkz

    (@bcworkz)

    The cause and solution would be theme specific, so we couldn’t say for sure. As a guess, you replaced the call to comments_template() with the code from your theme’s comments.php template file. comments_template() does a lot more than include comments.php, it makes a comments query and sets up several variables the template uses. By substituting, you’ve apparently taken out that critical functionality. At the very least you may need $comments = get_comments(); but it may take more than that.

    Why are you trying to merge template code into the same file anyway?

    Thread Starter Fawzi

    (@fauzurrahman15)

    i think because the comment only appear in single page, why not include it in single.php

    is it bad?

    Why would you only have comments in posts? Pages can have comments also, as well as other custom post types.

    Thread Starter Fawzi

    (@fauzurrahman15)

    custom post is using single.php
    single.php can be renamed to singular.php

    why separate file that used once? it’s understandable if header.php or footer.php

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Merge comments.php to single.php’ is closed to new replies.