In my blog index page I do not want to show posts which has empty content but only title (How does filter the_posts work?) . I am looking at 'the_post' hook which seems to fire inside the loop . So , I thought if the action hook is fired inside the loop I could check the post content on 'the_post' hook and if it is null continue with the loop . I tried the below :
add_action('the_post' , 'rb_test_the_post');
function rb_test_the_post($post){
if (($post->post_content) == '') {
continue;
}
}
This gives me an error in Wordpress ( "The site is experiencing technical difficulties " and also in my editor as it doesnt see any while or if statement for the continue statement.) . I am not able to understand why the continue statement doesnt work even though the hook is fired inside the loop .Could some one please explain?
Also , how would one achieve this (using a plugin and not the theme as I want the empty posts not to show even when I change theme) ?
$post
in the function call to$posts
in theif()
statement. As far as the function is concerned,$posts
is an uninitialized variable, and you're using it as though it's an object.WP_DEBUG
to see what the actual error is. The "WordPress is experiencing technical difficulties" error is a generic message that usually indicates there's a fatal error somewhere in your PHP code.