Remove shortcode from All in One SEO Pack in WordPress 2.6

Starting in WordPress 2.6, they’ve added captions to images that are automatically generated and use the Shortcode API to make it happen.  One side effect is that All in One SEO Pack isn’t set up to strip the caption from the automatically generated META tags, so you may end up with in your description.

Thanks to a WordPress Trac entry, I got the right regular expression to strip all shortcode in All in One plugin.

Make the following changes to fix the SEO pack problem:

Edit the file all_in_one_seo_pack.php.

On Line 1059, find:

function trim_excerpt_without_filters($text) {
$text = str_replace(']]>', ']]>', $text);

Below it, add:

$text = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $text );

On Line 1074, find:

function trim_excerpt_without_filters_full_length($text) {
$text = str_replace(']]>', ']]>', $text);

Below it, add:

$text = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $text );

That should do it!  Let me know if there are any issues that come up.

Related posts:

  1. Add Custom Taxonomy Title Tags Support to All-In-One SEO Pack
  2. SEO WordSpinner Plugin – A Killer SEO Plugin for WordPress
  3. Nofollow SEO for your WordPress Functions
  4. Gravity Forms Shortcode Explained
  5. Add Canonical Tags to Shopp Plugin for SEO

This entry was posted in Code and tagged , , , , , , , , , , , . Bookmark the permalink.
  • Pingback: How to turn off captions in WordPress 2.6 « Denver Web Design & Denver SEO - The Katz Web Design Blog

  • http://www.aikindo.com/ Aikindo

    Thanks for the fix, I have applied it and it work out successfully.

    One question, how long does it take for search engine to revisit and get the new description?

    Best regards…

  • Kevin

    Thank you very much for this fix

  • http://www.seodenver.com Zack Katz

    @Kevin – Glad to be of assistance.

  • Chris

    What does this line do? Anything?
    $text = str_replace(‘]]>’, ‘]]>’, $text);

  • http://www.seodenver.com Zack Katz

    @Chris – Now that you mention it, I have no idea. It would seem to search for ]]> then replace it with the same exact thing! Doesn’t make much sense, does it!?

  • Chris

    :) no. But thanks for the regex. I’ve used it to patch the_excerpt_reloaded plugin.

  • Alan

    Thanks. This worked perfectly for me.

  • http://www.themeparks-dubai.com/ ChuckMcB

    Excellent fix, working fine for me.

    Cheers

  • yair

    Awesome fix! Thanks Zack!

  • http://www.geektips.net Yogi

    Thanks for the patch mate, I worked like a charm :) .

  • http://www.thechetan.com/ Chetan

    But when ever we update our plugin it becomes as it was :( , we should suggest this to AIO SEO makers.

  • http://www.seodenver.com Zack Katz

    Ah, so true. What you could do is add a function in your functions.php file with the right hook…I can’t look into it now, but that may be a good way to avoid updating it!

  • http://www.seodenver.com Zack Katz

    @Aikindo — I just now saw your question. How often a search engine updates their index of your site depends on the site itself. For most of my clients with static websites, it’s about 2-3 weeks. Updated blog sites should be faster.

  • http://www.doubleblackdesign.com Keith

    Thanks for this tip! This post helped me to resolve a compatibility issue with the All in One SEO Pack plugin and the WP Remix theme. See my post below for more info…

    http://www.doubleblackdesign.com/wp/2009/01/18/all-in-one-seo-pack-and-wp-remix-theme-support/

  • http://www.642weather.com/ Mike

    I wonder why new versions of All in One SEO Pack plugin keep coming out without this fix?
    I have reported it, but they seem to ignore. Why?

    Lets contact and nicely ask it be added in:
    http://semperfiwebdesign.com/contact/

  • http://www.642weather.com/ Mike

    Good news!

    This is fixed in the latest All in One SEO Pack 1.4.7

    No need to worry about it anymore.

  • http://seosport.com/ Florida SEO

    I believe the WordPress plugin Platinum SEO Plugin is far superior to the All in One SEO Pack due to the fact that you can just do more! Below are a few of the features of the platinum seo pack that I like:

    •    use advanced title rewrite
    •    add canonical url’s
    •    adds the noodp meta tag
    •    adds the noydir meta tag
    •    nofollow external links on homepage
    •    noindex Rss feeds including comment feeds
    •    noindex comment pages of posts
    •    noindex date based archives
    •    Use categories for meta keywords
    •    add additional headers for pages and posts
    •    Autogenerate descriptions
    •    nofollow archive listings
    •    nofollow category pages
    •    nofollow tag pages
    •    nofollow search result pages
    •    log important events
    •    nofollow registration links
    •    track permalink changes as well!

    As a <a title=”Florida SEO” href=”http://seosport.com/florida-seo/”>Florida SEO</a> Company we have worked with many different WordPress websites and have found this to be the best SEO plugin ever made for WordPress SEO!!!