Is there a way to remove published comments so they're hidden for logged out users?
Based on an older article, this is how I would do it:
Note: This must be a stand-alone plugin; do not put this code into a theme.
But you can also search for all occurrences of
I would recommend looking for all occurrences of
Alternatively, you can open up your theme's
PHP let's you return out of files early, so you can "bail" from an include like the above. If you need to remove comments on ALL post types for non-logged in users, the second option is likely the best. If you need it conditionally on some post types, the first is the best.
The best solution, however, is to use your own filters. Rather than calling
Why do this? Much more flexible.
Want to show comments on certain posts? The first two options above don't let you do that (without some refactoring). Using your own filter makes things much more extensible for your future self -- or for end users if you're releasing the theme.
Thanks. I resolved this by writing the custom function myself based on removing the comments form from Genesis.