Comments in Protected Content after more tag

If I choose to protect content after the more tag in the Protected Content plugin...does that protect the comments as well for the posts where I use the more tag? If not, how do I go about just protecting comments on posts that should be protected?

Thanks!

  • Tyler Postle

    Hey Mahadigital,

    Hope you're doing well today and thanks for your question!

    The more tag will only protect content within the post itself. Comments our outside the post/page body so they won't be affected by the more tag protection. You likely noticed the comments protection option beside the more tag in Protected Content settings. Right now it's just all comments or no comments, I can put in a feature request for per post comment protection :slight_smile:

    An alternative could be to use CSS on specific posts, depending how many posts their are though it could get a bit repetitive.

    Protected Content adds a class of "ms-0" to the body of every page for a logged out user or visitor. So we can hide the comments box on certain pages/posts like this:

    .page-slug .ms-0 .postmetadata, .page-slug .ms-0 #comments_template {
    display: none;
    }

    Normally themes will have the post id or slug in the body class; however, yours doesn't, so we will have to add that in too :slight_smile: you can do that by adding this function to your themes functions.php class:

    //Page Slug Body Class
    function add_slug_body_class( $classes ) {
    global $post;
    if ( isset( $post ) ) {
    $classes[] = $post->post_type . '-' . $post->post_name;
    }
    return $classes;
    }
    add_filter( 'body_class', 'add_slug_body_class' );

    Then replace .page-slug in the above CSS with the page-{slug} of each page/post you want to hide the comments form on.

    Let us know if you have any further questions!

    All the best,
    Tyler

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.