WordPress.org

Ready to get started?Download WordPress

Forums

Change the status of many posts at once (5 posts)

  1. sabinou
    Member
    Posted 6 years ago #

    Hello,

    I need to change the status of 150 posts of my blog to "draft", do you know of any way to make it in a batch process, and not one by one ?

    Even if I should update values in the database, that would be better than having to make an update post by post. Of course, a plugin to do it nicely would be even better ;)

    Thank you VERY much if you can help :)

    Regards,

    Sabinou

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    If you want to manually deal with the database, then in the posts table, find the post and set the post_status column to the word "draft".

  3. sabinou
    Member
    Posted 6 years ago #

    I thought I have I had replied to you, I check the link, my reply wasn't there ? And I had already had to re-post my thread again after it didn't appear in the topics list... Either the WP forums have a glitch, either I'm too tired today.
    Oh well, I'll try a coffee soon.

    Thanks for the reply, Otto !

    As I *thought* I had written, I can change a post_status from "publish" to "draft" in wp_options, but with a total of 741 blog notes to this day, I'd love to be able to discriminate this. All of the blog notes that I want to set as draft are from a category that I want to remove temporarily.
    Can it be possible, in your opinion, Otto, to set as draft ONLY and ALL blog notes of a precise category ?

    I found the reference to the categories in wp_terms, but not in wp_options, alas, and I don't see how to cross the two references.

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Firstly, wp_options does not enter into it at all. I have no idea what you're looking at there.

    The post_status column in question is in wp_posts. That's what you need to set to "draft".

    To determine what category a post is in, you have to use the term relationships table along with the terms and taxonomy tables.

    Something like this:

    SELECT * FROM wp_posts
    LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
    LEFT JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)
    LEFT JOIN wp_terms ON (wp_terms.term_id = wp_term_taxonomy.term_id)
    WHERE
    wp_terms.name = "Category Name" AND
    wp_term_taxonomy.taxonomy = 'category'

  5. sabinou
    Member
    Posted 6 years ago #

    My mistake, I meant wp_posts, not options, indeed.

    I'll dig that question, i've got work to do to have an sql syntax allright, unfortunately :(
    Thanks for giving the me starting point, Otto :)

Topic Closed

This topic has been closed to new replies.

About this Topic