0

So, i did create a website with 110k posts and i need to test some SEO features, so i did clone the same database and i did post them on 5 other domains. The thing is i can't index them 110k posts at a single time by google cus it isn't gonna go up, so i need a code to posts like 5000 - 10000 posts per day onto a random time postbased.

I've tried this plugin https://wordpress.org/plugins/drafts-scheduler/ But it only allows 999 posts per day to be scheduled, i did try to modify the number of allowed characters on the php code but it doesn't work.

Thanks!

0

An way to do that is using SQL. You probably have access to the database, so you can run this daily. It's not automatic, but will solve your problem

UPDATE wp_posts SET post_status='publish' WHERE post_status='draft' AND post_type='post' ORDER BY rand() LIMIT 5000

Just to explain what this line do: It will get 5000 items (LIMIT 5000) in a random order (ORDER BY rand()) and will transform the status to published (post_status='publish') on every record that is a post (post_type='post') and the status is draft (post_status='draft').

Hope it helps :)

  • Works quite well! Thanks you André, theres a way to publish them randomly through the day? And also, there's a way the date added changes to the same time it is being published? Let me explain myself, i started the principal website on march 2016 and so a lot of posts still have this date in the database, so i need to change them automatically to the same time this SQL Query is working, Thanks buddy! – Alejandro Martín Apr 25 '16 at 19:44
  • @AlejandroMartín It's already random. About the date, you can do that by adding ", post_date=NOW(), post_date_gmt=NOW(), post_modified=NOW(), post_modified_gmt=NOW()" after post_status='publish'. The problem here is that you should consider the timezone in those _gmt fields, but since I'm not an expert in SQL I can't tell you how to do it. :( If you this helps, don't forget to choose as an answer ;) – André Gumieri Apr 25 '16 at 19:54
  • Im trying with this code UPDATE wpls_posts SET post_status='publish' post_date=NOW(+1) post_date_gmt=NOW(+1) post_modified=NOW(+1) post_modified_gmt=NOW(+1) WHERE post_status='draft' AND post_type='post' ORDER BY rand() LIMIT 1 but doesn't seem to work, what i am missing here? Thanks André – Alejandro Martín Apr 25 '16 at 20:04
  • @AlejandroMartín You've missed the commas :) UPDATE wpls_posts SET post_status='publish', post_date=NOW(), post_date_gmt=NOW(), post_modified=NOW(), post_modified_gmt=NOW() WHERE post_status='draft' AND post_type='post' ORDER BY rand() LIMIT 1 Also, the +1 inside NOW() doesn't take any effect. NOW doesn't accept parameters – André Gumieri Apr 25 '16 at 20:13
  • Thanks André, it is working perfectly now, how i can rate your question as the best answer? – Alejandro Martín Apr 25 '16 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.