• HI,

    I am using this code to add a comments to one of my pages. Do I need to add all lines of code for each new page that requires comments or is there a way to specify multiple pages within these lines of code.
    Thanks!!!

    <?php
    if (is_page(183)) {
    ?>
    <div class=”et_pb_row”>
    <?php
    comments_template( ”, true );
    }
    ?>
    </div>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Add this part:

    <?php
    comments_template( '', true );
    ?>

    to your page template(s) and comments will appear for all pages that are based on that template. You don’t need the conditional if is page 183 when you do it this way, assuming you want comments on all pages using this template. Use a different template for pages that should not have comments.

    You should create your own template based on your theme’s template and use that for all of your pages with comments. This way your modification is not lost when the theme updates. If you anticipate other modifications, create a child theme to contain them all and keep them protected.

    Thread Starter Radsterdriver

    (@radsterdriver)

    Hi,
    I’ve tried it but nothing changed.

    I’ve made a new template.

    Where should the code be placed?

    Should it replace ay other code?

    thanks.

    Moderator bcworkz

    (@bcworkz)

    The code goes on the template file that is specified when you create pages. The default one is page.php. Place the code where ever you want the comments to appear. The code is intended to go amongst HTML. If where you want the comments to appear is already PHP, do not add another <?php ?> block, just add the function call alone.

    There is not any need to remove any other code, unless it’s doing something you do not want.

    If you still are having trouble getting it working, set WP_DEBUG to true on your wp-config.php file. This will enable error messages to appear in your browser, telling you what and where there is a problem.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Adding comments to multiple pages? using’ is closed to new replies.