I know how to enable/disable comments on all pages. But how can I enable only a few, WITHOUT USING THE UI. In functions.php
I just wanna go
if($this_is_a_page_i_want_comments_on) { enable_comments(); }
enable_comments();
doesn’t exist, this is the part I need help with.
I could do this using WordPress Admin by allowing comments on all pages, then going to each page and disabling comments where I don’t want them. This would take too long though.
P.S. I’m using Genesis framework.
Simply hook to the
comments_open
filter 🙂 If you look-up in the source how thecomments_open()
function works, you’ll notice that the function gets the post in question and then runs it’s reposnse through thecomments_open
filter. Here’s an example function to override that:I assume that you know how you’ll identify the pages that you want to enable comments on – so that’s up to you.
PP: I don’t know if it will work in Genesis or not(I presume that it should though).
Not sure if there’s a better way, that’s just my solution!