WordPress.org

Forums

[resolved] Disable comments (totaly) on specific pages (5 posts)

  1. Ihks
    Member
    Posted 6 years ago #

    Hi,

    I am using WP as CMS, and I want to be able to create clean pages that does not show up in EventsCalender. I don't want there to be this sign "Comments have been disabled from this post" etc. beacuse for example on the Contact page this sort of message makes it feel bloggish and doesnt make sence.

    Example: http://victorsvedberg.se/katolskakyrkan/?page_id=27
    "Ännu har ingen lämnat någon kommentar
    Tyvärr, kommentarformuläret är för närvarande avstängt." Is swedish for "No comments here yet
    Sorry, comments is currently disabled". This is the thing I would like to get rid of on certain pages.

  2. churchthemer
    Member
    Posted 6 years ago #

    From what you are describing it sounds like the text that you want to get rid of is generated in the comments.php file versus the post meta section of usually found in single.php. I would take a look at your plugin or page.php file to find where it calling this:

    <?php comments_template(); ?>

    This could be on page.php, some custom template file or inside the plugins code. Once you find this section replace it with:

    <?php
    if(is_page('27')){
    }
    else{
      comments_template();
    }
    ?>

    In the above code 27 is the page id for the page you want to exclude the comments from. If you need to do this for more than 1 page id you can string together "or" statements like this:

    <?php
    if(is_page('27') || is_page('32') || is_page('56')){
    }
    else{
      comments_template();
    }
    ?>

    or if you are using WP 2.5 or better you can use the new array feature

    is_page(array(27,32,56))

    Hope that gets you headed in the right direction.

  3. Ihks
    Member
    Posted 6 years ago #

    Thanks alot! That solved my problem

  4. LilyGraison
    Member
    Posted 6 years ago #

    Hi,

    I've tried this and I can only get it to work on 3 pages and I have 9 total that I want this to work on. I've replaced the code using the long version and the 'array' and I still cannot get it to work. Any suggestions?

  5. colinsp
    Member
    Posted 5 years ago #

    Great thanks for this it has done what I needed too.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.