[Resolved] Want To Off Comment Some Category

Home Forums Support [Resolved] Want To Off Comment Some Category

Home Forums Support Want To Off Comment Some Category

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1577525
    Mehedi

    Hello Sir,
    hope you are doing well.i want to off comment box for some Category. Suppose My Category Name “Example Category”and Category id 100,So How Can off comment for this category?
    Thanks & Regards,
    Mehedi

    #1577798
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You could do this:

    add_filter( 'comments_open', function( $open, $post_id ) {
        if ( has_category( 100, $post_id ) ) {
            $open = false;
        }
    
        return $open;
    }, 10, 2 );
    #1578758
    Mehedi

    Function Not Working,when i add its functions.php all single post not open,i see blank page.
    Thanks

    #1578926
    Tom
    Lead Developer
    Lead Developer
    #1578979
    Mehedi

    Yes working sir,but my category id 98,99, i says 100 for example,i want to use any category id(single or multiple).just replace category id for On & Off comment.when i replace category id wp says syntax error.
    Thanks & Regards,
    Mehedi

    #1579147
    Elvin
    Staff
    Customer Support

    Hi,

    Did you place the category IDs properly?

    You’ll have to place the multiple IDs as an array.

    example:

    add_filter( 'comments_open', function( $open, $post_id ) {
        if ( has_category( array(98,99), $post_id ) ) {
            $open = false;
        }
    
        return $open;
    }, 10, 2 );

    Alternatively, you can use slugs or names.

    Example:

    add_filter( 'comments_open', function( $open, $post_id ) {
        if ( has_category( array('category_slug_1','category_slug_2'), $post_id ) ) {
            $open = false;
        }
    
        return $open;
    }, 10, 2 );

    A wise man once said:
    "Have you cleared your cache?"

    #1580236
    Mehedi

    Wow! Working ,i need more one help. i use DC Simple Share Buttons Plugins[https://wordpress.org/plugins/dc-simple-share-buttons/] For Social Share,i want to disabled Share option for Specific category, Like: Category ID: 98 How Can i Disabled that.
    Thanks & Regards,
    Mehedi

    #1580780
    Elvin
    Staff
    Customer Support

    Wow! Working ,i need more one help. i use DC Simple Share Buttons Plugins[https://wordpress.org/plugins/dc-simple-share-buttons/] For Social Share,i want to disabled Share option for Specific category, Like: Category ID: 98 How Can i Disabled that.

    Unfortunately, DC Simple Share Buttons is a third party plugin that is not within our scope of support.

    But to point you to a potential solution.

    If you want it hidden, you can do it with CSS placed within a Hook Element.

    Create a Hook Element and add this inside a Hook Element’s code area:

    <style>
    .entry-content > .myclass {
        display: none;
    }
    </style>

    You then set the Hook Element’s Display rule to the category you want this applied to.

    If you want it visible but disabled, you’ll need custom scripts.

    A wise man once said:
    "Have you cleared your cache?"

    #1580954
    Mehedi

    Wow Working! Thank You So Much.
    Regards,
    Mehedi

    #1580957
    Elvin
    Staff
    Customer Support

    No problem. Glad to be of any help. 😀

    A wise man once said:
    "Have you cleared your cache?"

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.