2

I slightly modified your code and tested on my Wordpress installation. If you using a filter, like 'the_content', which recieves a content as an argument, you must also return this content back. Here is working version of your function with comments. //this filter recieves $content, which you should always return, //otherwise you will not see the content ...


1

If you want to use the the_ functions (e.g. the_permalink() and the_title()) and including in_category() (without specifying the second parameter) outside of The Loop (the standard one which calls the_post()), you should access the global $post variable and call setup_postdata() to set up global post data and after your foreach ends, call wp_reset_postdata() ...


Only top voted, non community-wiki answers of a minimum length are eligible