Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Removing some pattern from wp_posts post_excerpt column WordPress

  • SOLVED

Ok ,First i want to know you all that i am trying to migrate from xoops to wordpress.I think all of you know about XOOPS Cms. I have a problem that i can't resolve.

My wp_posts table post_excerpt column have data like this

[url=http://www.localhost/portal/uploads/different_imagenames.jpg][img align=right]http://www.localhost/portal/uploads/different_imagenames.jpg[/img][/url] Some text here

some are like this also
[img align=right]http://www.localhost/portal/uploads/different_imagenames.jpg[/img] Some text here

some are

[img]http://www.localhost/portal/uploads/different_imagenames.jpg[/img] Some text here


I want only clean data like that will be like this

Some text here


I tried almost everything but no success.Also tried http://wpquestions.com/question/showChrono/id/2089

Please help me anyone.

Answers (1)

2014-09-12

timDesain Nanang answers:

Have you tried these function:
- http://codex.wordpress.org/Function_Reference/strip_shortcodes
- http://codex.wordpress.org/Function_Reference/remove_all_shortcodes


bappa2543 comments:

but the shortcodes are not for wordpress.they belong to xoops.will it work??


timDesain Nanang comments:

put this code in the theme's functions.php:

add_shortcode( 'img', 'wpq_dummy_sc' );
add_shortcode( 'url', 'wpq_dummy_sc' );
function wpq_dummy_sc( $atts, $content="" ) {
return $content;
}


get the excerpt:

<?php echo strip_shortcodes( get_the_excerpt() ); ?>


bappa2543 comments:

ok it works but how can i format the content in post_exceprt column.I am also using all in seo plugin which pulls content from this post_exceprt column. so i see a meta description like
<strong>[url=http://www.localhost/portal/uploads/different_imagenames.jpg][img align=right]http://www.localhost/portal/uploads/different_imagenames.jpg[/img][/url]
Some text here
</strong>


not like this

Some text here


bappa2543 comments:

is there any way to delete the unnecessary codes from the post_excerpt column in database to work like this.


timDesain Nanang comments:

I am sorry, I was away.

Yep, you need to create a custom query: [[LINK href="http://codex.wordpress.org/Function_Reference/wp_update_post"]]wp_update_post[[/LINK]] and [[LINK href="http://codex.wordpress.org/Function_Reference/update_post_meta"]]update_post_meta[[/LINK]]
within [[LINK href="http://codex.wordpress.org/The_Loop"]]the loop[[/LINK]]