- This topic has 9 replies, 3 voices, and was last updated 3 years, 4 months ago by Elvin.
-
AuthorPosts
-
December 12, 2020 at 7:41 am #1577525Mehedi
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,
MehediDecember 12, 2020 at 11:52 am #1577798TomLead DeveloperLead DeveloperHi 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 );
December 13, 2020 at 8:51 am #1578758MehediFunction Not Working,when i add its functions.php all single post not open,i see blank page.
ThanksDecember 13, 2020 at 11:28 am #1578926TomLead DeveloperLead DeveloperCan you try it now?
December 13, 2020 at 11:59 am #1578979MehediYes 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,
MehediDecember 13, 2020 at 4:37 pm #1579147ElvinStaffCustomer SupportHi,
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 );
December 14, 2020 at 8:31 am #1580236MehediWow! 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,
MehediDecember 14, 2020 at 5:04 pm #1580780ElvinStaffCustomer SupportWow! 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.
December 14, 2020 at 10:56 pm #1580954MehediWow Working! Thank You So Much.
Regards,
MehediDecember 14, 2020 at 10:58 pm #1580957ElvinStaffCustomer SupportNo problem. Glad to be of any help. 😀
-
AuthorPosts
- You must be logged in to reply to this topic.