knewton
Member
Posted 11 months ago #
Hi. I created a plug-in to use in my web site that adds content to a custom post type (audio_music). The plug-in works great for my custom posts but on all other pages the content is not shown. Only the title of the post and the comments box remains. Whenever I remove the filter ( add_filter ('the_content', 'my_filter_the_content')) the other pages and posts work fine but my plug in is broken. The same happens when I deactivate the plugin. There are no other plugins running when I test this. Suggestions? Here is the code:
[code moderated - please use the http://pastebin.com/ ]
knewton
Member
Posted 11 months ago #
correction - the post type is called "audio_posts" not "audio_music"
http://codex.wordpress.org/Plugin_API#Create_a_Filter_Function
don't echo or print any output from within a filter - the filter needs to return the content.
knewton
Member
Posted 11 months ago #
So I changed 'echo' to 'return' and I still have the same issue. Suggestions?
please paste the code of your plugin into a http://pastebin.com/ and post the link to it here.
knewton
Member
Posted 11 months ago #
knewton
Member
Posted 11 months ago #
I fixed the issues by adding this:
function audio_accessible($content) {
/* If this is NOT audio_post (custom post type), then simply return the content*/
if (!is_singular ('audio_posts')) {
return $content;
}
[Please post code snippets between backticks or use the code button.]