Categories
Code

Remove [caption] 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.

By Zack Katz

Zack Katz is the founder of GravityKit and TrustedLogin. He lives in Leverett, Massachusetts with his wife Juniper.

18 replies on “Remove [caption] shortcode from All in One SEO Pack in WordPress 2.6”

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…

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!

@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.

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!!!

Comments are closed.