Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 06-09-2016, 06:25 AM   #1
klinton
So Fucking Banned
 
Industry Role:
Join Date: Apr 2003
Location: online
Posts: 8,766
wordpress help - link all texts in al posts

So basically I would like to bulk edit all posts that I have and link whole text that is in every post to some url....
how to do that ? please dont post answers with plugins like search regex, search and replace and so on..unless you know exact php syntax to do this task... in that case - you are very welcome, thx
klinton is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-09-2016, 07:08 AM   #2
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Do you have access to MYSQL for the site? Either from the command line or something like PHPMyadmin?

If you do then your easiest solution is just to do it with a couple of sql calls, at least if all posts are going to all link to the same thing.

1. Make a copy of the wp_posts table.

create table wp_posts_backup select * from wp_posts

2. Make the changes to the wp_posts table.

update wp_posts set post_content='<a href="http://url_to_link_to_goes_here">' + trim(post_content) + '</a>'

Now all posts should be linked to whatever url you specified.

There is danger in there if you have any quotation marks(") within the post_content itself. In that case the query would have to be worked a bit to handle that.

If you want to selectively update posts, meaning when you have something in the text go to one url and when you have something else go to another url then you would use the where clause to designate what's what.

example. update anything that mentions cams.com to link to your cams.com url and anything that mentions chaturbate to link to your chaturbate url.

Cams.com update: update wp_posts set post_content='<a href="http://cams.com_url_goes_here">' + trim(post_content) + '</a>' where post_content like '%cams.com%'

Chaturbate update: update wp_posts set post_content='<a href="http://chaturbate.com_url_goes_here">' + trim(post_content) + '</a>' where post_content like '%chaturbate.com%'

You could also handle multiple conditions within one query by using a case statement:

update wp_posts set post_content='<a href="' +
case
when instr(post_content,'chaturbate.com')>0 then 'http://chaturbate.com_url_goes_here'
when instr(post_content,'cams.com')>0 then 'http://cams.com_url_goes_here'
else
'http://default_url_goes_here'
end
+ '">' + trim(post_content) + '</a>'

There are many other ways to do it but these are probably the most straight forward.

If you go back to the site and no posts show then you got something wrong in there and you need to look at the post text and debug to figure out what you need to do. If needed you drop back to the backup table.

This takes care of the posts currently on the site. It does NOT take care of future posts.

This can all be very dangerous. USE AT YOUR OWN RISK AND DON'T COME BLAMING ME IF YOU FUCK IT UP.

I also do not guarantee the syntax as I wrote it. I did it off the top of my head and I could have a quote mark or apostrophe wrong in there. I always suggest you test stuff and make sure you have it write before committing yourself. As always the information contained in this post might be worth exactly what you paid for it.

Hope that helps.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-09-2016, 07:20 AM   #3
klinton
So Fucking Banned
 
Industry Role:
Join Date: Apr 2003
Location: online
Posts: 8,766
yeah, thank you very much.... what do you mean that it only works for current posts ?
I would like to edit drafts (that are scheduled) that way too....Actually most of the posts are drafts...
any other idea how to do that using plugins like search regex and search and replace ? what is the syntax over there (PHP syntax, regex) to mark all text found in all posts and link it to some url ? any idea ?



Quote:
Originally Posted by sarettah View Post
Do you have access to MYSQL for the site? Either from the command line or something like PHPMyadmin?

If you do then your easiest solution is just to do it with a couple of sql calls, at least if all posts are going to all link to the same thing.

1. Make a copy of the wp_posts table.

create table wp_posts_backup select * from wp_posts

2. Make the changes to the wp_posts table.

update wp_posts set post_content='<a href="http://url_to_link_to_goes_here">' + trim(post_content) + '</a>'

Now all posts should be linked to whatever url you specified.

There is danger in there if you have any quotation marks(") within the post_content itself. In that case the query would have to be worked a bit to handle that.

If you want to selectively update posts, meaning when you have something in the text go to one url and when you have something else go to another url then you would use the where clause to designate what's what.

example. update anything that mentions cams.com to link to your cams.com url and anything that mentions chaturbate to link to your chaturbate url.

Cams.com update: update wp_posts set post_content='<a href="http://cams.com_url_goes_here">' + trim(post_content) + '</a>' where post_content like '%cams.com%'

Chaturbate update: update wp_posts set post_content='<a href="http://chaturbate.com_url_goes_here">' + trim(post_content) + '</a>' where post_content like '%chaturbate.com%'

You could also handle multiple conditions within one query by using a case statement:

update wp_posts set post_content='<a href="' +
case
when instr(post_content,'chaturbate.com')>0 then 'http://chaturbate.com_url_goes_here'
when instr(post_content,'cams.com')>0 then 'http://cams.com_url_goes_here'
else
'http://default_url_goes_here'
end
+ '">' + trim(post_content) + '</a>'

There are many other ways to do it but these are probably the most straight forward.

If you go back to the site and no posts show then you got something wrong in there and you need to look at the post text and debug to figure out what you need to do. If needed you drop back to the backup table.

This takes care of the posts currently on the site. It does NOT take care of future posts.

This can all be very dangerous. USE AT YOUR OWN RISK AND DON'T COME BLAMING ME IF YOU FUCK IT UP.

I also do not guarantee the syntax as I wrote it. I did it off the top of my head and I could have a quote mark or apostrophe wrong in there. I always suggest you test stuff and make sure you have it write before committing yourself. As always the information contained in this post might be worth exactly what you paid for it.

Hope that helps.

.
klinton is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-09-2016, 07:31 AM   #4
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by klinton View Post
yeah, thank you very much.... what do you mean that it only works for current posts ?
It means that the sql is only going to change posts that are currently in the database. It is not going to automatically do anything to future posts. They do not exist yet so they will not be changed.

I have no idea on what plugins you might use for this going forward.

As far as doing it to a post that you are writing then just include the link when you create the post I would think.

I just tested on one of my wife's wp installs and it worked just fine. The posts I made was:

<a href="http://url_to_use.com">This is a test post</a>

It made a post that was linked.


.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-09-2016, 07:39 AM   #5
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Ok, I had missed that you said posts that are scheduled. YES, those would be changed in the method I outlined using sql calls.

All posts in the posts table could/would be affected. Scheduled posts are in the posts table with a future date so they would be changed.

Sorry I missed that part in my answer.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-09-2016, 07:40 AM   #6
klinton
So Fucking Banned
 
Industry Role:
Join Date: Apr 2003
Location: online
Posts: 8,766
who would expect that ?

any idea on php regex to mark whole text in posts ? in MS-DOS system it was usually *.*, but how about PHP ?
Quote:
Originally Posted by sarettah View Post
It means that the sql is only going to change posts that are currently in the database. It is not going to automatically do anything to future posts. They do not exist yet so they will not be changed.
.
klinton is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-09-2016, 07:46 AM   #7
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by klinton View Post
who would expect that ?

any idea on php regex to mark whole text in posts ? in MS-DOS system it was usually *.*, but how about PHP ?

I am not sure what you are asking. I understand regex, I understand php, I even understand your wildcard using DOS. But I do not understand how you are thinking to use regex when changing posts.

The posts are in a database so they either have to be changed while they are going in or when they come out (being displayed).

I do not see either of those requiring regex although if you modified the php being used to display the posts as they come out you could use regex in there but there are other ways to do it too.

What are you wanting the regex to match to? Meaning, are you changing things conditionally (as I described above where one goes to cams and the other to chaturbate) or is everything going to link to the same thing or what?

Sorry for seeming dense.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-09-2016, 08:06 AM   #8
klinton
So Fucking Banned
 
Industry Role:
Join Date: Apr 2003
Location: online
Posts: 8,766
there is one wordpress plugin called "search regex" which is handful for me.
yesterday I used it to bulk modify all posts that contained some url like url.com/variablehere to steadyurl.com
I did it using some PHP magic delimiter like
Code:
/<a [^>]+>/i
which basically searched for all urls in posts, marked them and changed them to my new url, specified before in the plugin field "replace with"...
now, my queston is: what would be PHP delimiter to mark whole text in that plugin and later modify it with adding just
Code:
<a href="http://www.myurl.com">
at the beginning.
is it even possible ?
I prefer to use that plugin instead of php my admin somehow, it has safe option like just "search" "search and replace without saving" and so on
Quote:
Originally Posted by sarettah View Post
I am not sure what you are asking. I understand regex, I understand php, I even understand your wildcard using DOS. But I do not understand how you are thinking to use regex when changing posts.

The posts are in a database so they either have to be changed while they are going in or when they come out (being displayed).

I do not see either of those requiring regex although if you modified the php being used to display the posts as they come out you could use regex in there but there are other ways to do it too.

What are you wanting the regex to match to? Meaning, are you changing things conditionally (as I described above where one goes to cams and the other to chaturbate) or is everything going to link to the same thing or what?

Sorry for seeming dense.

.
klinton is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-09-2016, 08:11 AM   #9
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by klinton View Post
there is one wordpress plugin called "search regex" which is handful for me.
yesterday I used it to bulk modify all posts that contained some url like url.com/variablehere to steadyurl.com
I did it using some PHP magic delimiter like
Code:
/<a [^>]+>/i
which basically searched for all urls in posts, marked them and changed them to my new url, specified before in the plugin field "replace with"...

now, my queston is: what would be PHP delimiter to mark whole text in that plugin and later modify it with adding just
Code:
<a href="http://www.myurl.com">
at the beginning.

is it even possible ?

I prefer to use that plugin instead of php my admin somehow, it has safe option like just "search" "search and replace without saving" and so on
I don't know anything about that plugin, sorry about that. However the regex expression to match everything should be .* (dot and asterick).

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-09-2016, 08:14 AM   #10
johnnyloadproductions
Account Shutdown
 
Industry Role:
Join Date: Oct 2008
Location: Gone
Posts: 3,611
Klinton I sent you a PM with my info, read it.

Contact the email if you have interest.

I can fix all the current links but won't be doing anything for future links.
johnnyloadproductions is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-09-2016, 09:27 AM   #11
moln4r
Confirmed User
 
moln4r's Avatar
 
Industry Role:
Join Date: Apr 2010
Location: Budapest
Posts: 146
If you want contextual links there is a plugin I used somewhere in 2010 what can link any word in the whole site to any url.drop a pm if interested i do search for it.
moln4r is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-09-2016, 09:56 AM   #12
klinton
So Fucking Banned
 
Industry Role:
Join Date: Apr 2003
Location: online
Posts: 8,766
got one already that is called "seo autolinker"... however, the thing is that I actually would like to link whole text in all posts to some url....
so it looks like that I will have to do it via php my admin....
if you know how to do it in search regex plugin or search and replace plugin, you may let me/us know ;]
Quote:
Originally Posted by moln4r View Post
If you want contextual links there is a plugin I used somewhere in 2010 what can link any word in the whole site to any url.drop a pm if interested i do search for it.
klinton is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-09-2016, 06:30 PM   #13
SpeedoDave
Confirmed User
 
SpeedoDave's Avatar
 
Industry Role:
Join Date: Sep 2003
Location: Aussie until we are convicts no more.
Posts: 354
Sarettah,
Awesome response mate.
Dave

QUOTE=sarettah;20951015]Do you have access to MYSQL for the site? Either from the command line or something like PHPMyadmin?

If you do then your easiest solution is just to do it with a couple of sql calls, at least if all posts are going to all link to the same thing.

1. Make a copy of the wp_posts table.

create table wp_posts_backup select * from wp_posts

2. Make the changes to the wp_posts table.

update wp_posts set post_content='<a href="http://url_to_link_to_goes_here">' + trim(post_content) + '</a>'

Now all posts should be linked to whatever url you specified.

There is danger in there if you have any quotation marks(") within the post_content itself. In that case the query would have to be worked a bit to handle that.

If you want to selectively update posts, meaning when you have something in the text go to one url and when you have something else go to another url then you would use the where clause to designate what's what.

example. update anything that mentions cams.com to link to your cams.com url and anything that mentions chaturbate to link to your chaturbate url.

Cams.com update: update wp_posts set post_content='<a href="http://cams.com_url_goes_here">' + trim(post_content) + '</a>' where post_content like '%cams.com%'

Chaturbate update: update wp_posts set post_content='<a href="http://chaturbate.com_url_goes_here">' + trim(post_content) + '</a>' where post_content like '%chaturbate.com%'

You could also handle multiple conditions within one query by using a case statement:

update wp_posts set post_content='<a href="' +
case
when instr(post_content,'chaturbate.com')>0 then 'http://chaturbate.com_url_goes_here'
when instr(post_content,'cams.com')>0 then 'http://cams.com_url_goes_here'
else
'http://default_url_goes_here'
end
+ '">' + trim(post_content) + '</a>'

There are many other ways to do it but these are probably the most straight forward.

If you go back to the site and no posts show then you got something wrong in there and you need to look at the post text and debug to figure out what you need to do. If needed you drop back to the backup table.

This takes care of the posts currently on the site. It does NOT take care of future posts.

This can all be very dangerous. USE AT YOUR OWN RISK AND DON'T COME BLAMING ME IF YOU FUCK IT UP.

I also do not guarantee the syntax as I wrote it. I did it off the top of my head and I could have a quote mark or apostrophe wrong in there. I always suggest you test stuff and make sure you have it write before committing yourself. As always the information contained in this post might be worth exactly what you paid for it.

Hope that helps.

.[/QUOTE]
__________________
I feel old since I started SpeedoFetish.com back in 2001.
SpeedoDave is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-09-2016, 08:01 PM   #14
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by SpeedoDave View Post
Sarettah,
Awesome response mate.
Dave
Except that I screwed up a bunch of syntax. My brain fell away from mysql and dropped back to a different sql that understands + as the concat operator.

Oh well.

So every where that I did the + in the queries should have used a concat() function instead.

I also should have a where condition to see if post_content has anything in it.

So, the examples I used up there will not work and instead need to look like this:


update wp_posts set post_content=concat('<a href="http://url_to_link_to_goes_here">',trim(post_content),'</a>') where trim(post_content)>''

Cams.com update: update wp_posts set post_content=concat('<a href="http://cams.com_url_goes_here">', trim(post_content), '</a>') where post_content like '%cams.com%' and trim(post_content)>''

Chaturbate update: update wp_posts set post_content=concat('<a href="http://chaturbate.com_url_goes_here">', trim(post_content), '</a>') where post_content like '%chaturbate.com%' and trim(post_content)>''

update wp_posts set post_content=concat('<a href="',
case
when instr(post_content,'chaturbate.com')>0 then 'http://chaturbate.com_url_goes_here'
when instr(post_content,'cams.com')>0 then 'http://cams.com_url_goes_here'
else
'http://default_url_goes_here'
end
, '">' , trim(post_content) , '</a>') where trim(post_content)>''


I hate when I fuck up like that. It seems to happen about 4 billion times a day

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
post, search, posts, link, replace, regex, exact, thx, winkwink, plugins, syntax, task, php, bulk, edit, basically, texts, text, answers, url, wordpress



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.