How to stop echoing gallery inside content?

I want to completely stop echoing gallery inside the_content() because I am showing it in different position outside content as per design (with a help of get_post_gallery_images()). It is a custom theme from scratch, there are almost no plugins yet installed, I have tried it with this, but it does nothing.

add_filter(‘post_gallery’, ‘__return_false’, 999);

This only works partially, if I return empty string it still shows gallery, but if I return some string it shows that instead.

add_filter(‘post_gallery’, ‘test’, 999999);
function test() {
return ”; // Shows gallery
return ‘asdfasdf’; // Doesn’t show gallery but outputs this string
}

Read more here:: How to stop echoing gallery inside content?

Leave a Reply

Your email address will not be published. Required fields are marked *