Search code examples
wordpresspluginsfiltershortcode

Wordpress: the_content filter kills gallery shortcode


My the_content filter kills gallery shortcode and I dont know where the problem is... I can add just blank the_content filter and gallery disappear from the content and there is just [gallery] text. I am using the_content filter:

function test($data){
    echo $data;
}
add_filter('the_content', 'test');

Any suggestion how to fix it?


Solution

  • This is a common mistake, you just need to return the information to keep applying new filters, so change the function tho this:

    function test($data){
        //apply here any content modification then return new content
        return $data;
    }
    add_filter('the_content', 'test');
    

    You can get more information at: http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content