GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   search and replace part of url in wordpress posts?? (https://gfy.com/showthread.php?t=1027840)

roly 06-24-2011 09:31 AM

search and replace part of url in wordpress posts??
 
hi

just a quick question. i need to modify part of a url in lots of posts in some wordpress blogs. the table and field is wp_posts post_content so if some of these posts contain the url http://www.somesite.com/folder and i want to change it to http://www.anothersite.com/folder does anyone know what sql i should use in phpmyadmin to make this change on all the posts?

there's obviously other text in the posts to be changed that i want left alone its just a particular url i want to change.

any help appreciated, thanks in advance

roly 06-24-2011 09:50 AM

it's ok got it now:

UPDATE tablename SET tablefield = replace(tablefield,"findstring","replacestring");

cooldude7 06-24-2011 10:47 AM

nxt time try search and replace.


or for critical tasks, try regex replace

scouser 06-24-2011 12:12 PM

u can also write a wp plugin to do this really easily

something like this (untested)


add_filter('the_content','myreplacer');
function myreplacer($s) { return str_replace('from','to',$s); }


will want to add the_extract possibly too to add_filter.

fris 06-24-2011 04:32 PM

Quote:

Originally Posted by roly (Post 18237659)
hi

just a quick question. i need to modify part of a url in lots of posts in some wordpress blogs. the table and field is wp_posts post_content so if some of these posts contain the url http://www.somesite.com/folder and i want to change it to http://www.anothersite.com/folder does anyone know what sql i should use in phpmyadmin to make this change on all the posts?

there's obviously other text in the posts to be changed that i want left alone its just a particular url i want to change.

any help appreciated, thanks in advance

http://wordpress.org/extend/plugins/search-and-replace/

JD 06-24-2011 08:08 PM

Quote:

Originally Posted by fris (Post 18238565)

:thumbsup:thumbsup


All times are GMT -7. The time now is 06:51 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123