Here is database ss. And comment_status is closed
But when i print it, it shows open
echo $post->comment_status;
Also, in page settings, comments checkbox is unchecked.
So, i can't hide comments in pages. How can i fix it?
Here is database ss. And comment_status is closed
But when i print it, it shows open
echo $post->comment_status;
Also, in page settings, comments checkbox is unchecked.
So, i can't hide comments in pages. How can i fix it?
First thing I would do to debug such case is printing $post->ID
just before printing the comment status. (And make sure if it is equal to 414 - the post you’re checking in DB)
I’m almost certain that somewhere in your page you make another wp_query and modify the global $post
variable. So when you’re printing the comment status it’s showing the real value but for different post.
If you do such wp_query, then you'll have to remember to use wp_reset_postdata
after that loop, so the global $post
variable is restored to its original value.
$post
variable? – Krzysiek Dróżdż Commented Mar 5, 2019 at 10:32