Forums

[resolved] turn comments off in pages (classic based theme) (8 posts)

  1. AzaraT
    Member
    Posted 3 years ago #

    Hi there

    I just got started with wordpress and so far its easy and nice :) I've made a new theme for my site that is based on the classic template. However I want to make some static pages with no comments. And yes I know you can turn comments off in the admin panel. But it still shows:

    "Comments:

    No comments yet.

    Sorry, the comment form is closed at this time."

    I tried editing some stuff in the comments.php file but with no success. So how do i do this. I only want comments on posts but not on pages as it is in the "defualt" theme (couldn't adapt the changes from there, it seems to have a page.php file, but if I just copy it over to my theme it makes no differnce)

    Hope someone can help, thanks!

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    Didn't test this but in your wp-content/themes/classic/index.php file:
    change this:

    <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>

    to this:

    <?php if ( !$is_page ) { ?>
    <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>
    ?php } ?>

    Resources:
    Conditional Tags
    Stepping Into Templates
    Template Hierarchy
    Stepping Into Template Tags

  3. ClaytonJames
    Member
    Posted 3 years ago #

    You can try removing this from your custom page template and see what happens;

    <?php comments_template();?>

    Then continue editing the template to suit your design needs.

    Some possibly relevant reading; http://codex.wordpress.org/Include_Tags

    [Edit] Or, what MichaelH said. I must think way too simple for my own good! Darn you guys who actually know what you are doing! (shakes fist in air), Darn you all!

    :-)

  4. AzaraT
    Member
    Posted 3 years ago #

    didn't change anything.

    It is not the "Comments (1)" on the frontpage i need to change (which is the code you are editing atm?) its when you allready are in a page i need to take the comments away.

    my custom page templete doesn't work??

  5. ClaytonJames
    Member
    Posted 3 years ago #

    @AzaraT,
    My apologies, I just actually looked at the classic theme. You are going to want to go with MichaelH on this one.

  6. AzaraT
    Member
    Posted 3 years ago #

    hehe :) No worries, thanks anyway ;)

  7. moshu
    Member
    Posted 3 years ago #

    For those that don't know code...
    Save the index.php as page.php (this is for the Classic theme, which is lacking most of the template files!) and edit out/delete everything you don't need. Done.

  8. AzaraT
    Member
    Posted 3 years ago #

    ah thanks, worked as a charm. :D

Topic Closed

This topic has been closed to new replies.

About this Topic