Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I used remove_shortcode('gallery'); ...the gallery is gone, but the shortcode is visible in the text. How do I remove sitewide? I've searched for sql queries, but no solution fixes my specific problem.

gallery shortcode still visible

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

The short code is actually entered into then page or post content so disabling the short code processing prevents the gallery short code from being replaced with the gallery images but it doesn't affect the post content.

The best solution is to add a new short code handler after removing the default gallery handles. Another less desirable approach would be to remove the short code tag from all posts and pages.

Short code replacement would look something like this:

function no_gallery($atts) {
    return "";
}
add_shortcode('gallery', 'no_gallery');
share|improve this answer
    
+1, synchronized with the sensei, but 1 line of code better than 4 ;) –  brasofilo Jan 10 '13 at 9:38
add comment

You can make it invisible with a simple trick:

add_shortcode( 'gallery', '__return_false' );

This will remove the code from output without touching the post content.

share|improve this answer
1  
Nice trick! A single line of code instead of a lengthy process. +1 –  bungeshea Jan 10 '13 at 7:25
    
@bungeshea, this guy is a magician of higher arts, I'm still waiting for a trick in his magic bag that won't surprise me ;) –  brasofilo Jan 10 '13 at 9:35
add comment

The empty shortcode is a very nice trick, but if you want to remove the string [gallery] from all posts, there are two options: manually in the dashboard or a database search/replace.

Although the database could be manipulated directly, in those cases (content replacement), I prefer to use the plugin Search and Replace, by Frank Bültge.

As any database manipulation, backing up is essential.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.