R
R
Rainsteel2014-02-26 14:46:35
MySQL
Rainsteel, 2014-02-26 14:46:35

Sql query to publish wordpress post if there is a certain link in the text

please tell me how to correctly form a query to the wordpress database,
I need to check in one table whether there are links in a post like letitbit.net (data in an arbitrary field), if there are such links, then in another table that refers to the same post in the post_status field, put publish , that is, publish the entry.
into what I got:
SELECT meta_value FROM wp_postmeta WHERE meta_value LIKE ' http://letitbit.net/% ';
-shows me all posts with a link letitbit.net
UPDATE wp_posts SET post_status = 'publish'
this should change the value of the post to "published"
But I don't understand how to put it together =(.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander Litvinov, 2014-02-26
@Rainsteel

Try this

UPDATE `wp_posts`  SET `post_status`='publish' WHERE `id` in (SELECT DISTINCT `post_id` as `id` FROM `wp_postmeta` WHERE `meta_value` LIKE '%letitbit.net%')

R
Rainsteel, 2014-02-26
@Rainsteel

it is possible, but how to transfer it correctly?

R
Rainsteel, 2014-02-26
@Rainsteel

wp_posts table columns:
ID
post_author
post_date
post_date_gmt
post_content
post_title
post_excerpt
post_status
comment_status
ping_status
post_password
post_name
to_ping
pinged
post_modified
post_modified_gmt
post_content_filtered
post_parent
guid
menu_order
post_type
post_mime_type
comment_count
__________
wp_postmeta table columns:
meta_id
post_id
meta_key
meta_key

R
Rainsteel, 2014-02-26
@Rainsteel

everything is ok, thanks dude, I don't know what I would do without you!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question