Dont display post with no content
-
In my blog index page I do not want to show posts which has empty content but only title . 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 code 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) ?
- The topic ‘Dont display post with no content’ is closed to new replies.