• ZPWeeks

    (@zpweeks)


    WordPress currently applies bulk actions and edits only to posts shown on the posts screen at a given time. If a site has more than a few hundred posts, it’s not really feasible to display them all on the current posts screen – load speeds go down like crazy even on dedicated hardware.

    So what happens if a content manager wants to delete all their posts or move them to the trash? (This is my use case I’ve found myself running into on multiple projects, though there may be others.) They can:

    • Tell WordPress to show them many posts at a time (100-500?) , then try to delete them. But the delete command is sent in the URL string, so you had better not delete so many that the web server rejects a string for being too long.
    • Page endlessly through a smaller amount of posts and delete them. Which is less likely to generate errors, but still takes a ton of repetitive human action time for a scriptable task.
    • Install a plugin to remove posts. But only if they have the ability and permissions to do so. (This is a problem on, say, WordPress.com or other environments where the user isn’t an administrator.)
    • Circumvent WordPress and drop posts from the database. Nice and fast, but (a) not everyone has DB access and (b) hacking on core tables is dangerous business.

    I think Gmail has a quite elegant solution for bulk actions in their table of messages. “Select all” defaults to just selecting all emails onscreen, but additionally shows this option to select every post in the system. (If the user chooses to do so, they receive this confirmation.)

    Could WordPress add something similar to the core with bulk edits or actions? I can think of several upsides:

    1. Reduction of load and amount of queries to display many pages worth of posts then perform many DB updates to modify them (all with additional request time and browser load to display many posts)
    2. Ability to mass manage content without the need for plugins
    3. Reduction of information that needs to be passed between client, web server, PHP, MySQL
    4. Doesn’t tempt me to just drop rows manually in MySQL

    In thinking of this issue, I can already see a few challenges that others might be better off to address:

    1. Scalability. I want to just do a bulk action on ~1,500 posts at a time, but what about a site that has far more posts and wants to use the same functions? (Personally, I think the current way sucks just as much for both, so a reasonable way to handle large requests would be an improvement regardless.
    2. Resource demand. The current way defaults to 20 posts per page and keeps most requests nice and short. Depending on how it’s implemented, might it require a long-executing PHP process with lots of memory needs? I think this would be far more likely with a bulk edit like adding or deleting categories.

    What say ye? To me this kind of content management task, while not an everyday one, is best solved in core, since not all content managers have access to plugin alternatives.

Viewing 15 replies - 1 through 15 (of 17 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    If you want to delete ALL posts, you could probably do that best via a straight up SQL query. That said, the times you want to delete the posts on a site are fairly rare, and normally come about when someone wants to start over. At that point, you generally delete the whole site and start over everything. Especially since deleting a post doesn’t delete your uploaded images…

    I have moved all my various blogs into a single wordpress.org site. I now have 72 pages of mixed posts: some I want public, but some I *need* private. I’d love to make all my old posts private and then, over the coming weeks, go through and make visible again the ones that I want public. To do this currently I would have to ‘bulk’ edit 72 times!

    I think ZPWeeks’ suggestion of a proper global edit is great. As it is I’m just shutting my whole site down because I haven’t got the time/inclination to repeat the same task 72 times when a simple ‘select all’ option as in GMail would sort it in seconds.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Still best done with SQL.

    UNTESTED suggestion:

    UPDATE wp_posts SET post_status= 'private' WHERE post_staus = 'publish';

    This should look for all posts that are published and flip them to private.

    It would be ‘best’ if I had any idea how to do a SQL query… 🙁

    Not sure how it can be defined as ‘best’ when many people using wordpress.org can’t do it.

    This was posted on these forums 5 years ago:

    Use the following SQL commands:

    UPDATE wp_posts SET post_status=’STATUS’;

    Replace STATUS with private or public. This edits all posts by every user. If you have multiple authors and only want to edit one, you may use the following:

    UPDATE wp_posts SET post_status=’STATUS’ WHERE post_author=’NUMBER’;

    Remember to replace NUMBER with the correct ID number of the author.

    But as I don’t know how SQL queries work I hoped there’d be an answer within the admin settings.

    (zpweeks here on my more up-to-date profile…)

    I think there’s a strong case to be made for this content management need to be addressed though WordPress UI instead of limiting the ability to those that know SQL and have permission to execute queries on their WP instance. (Not to mention the fact that hacking on tables is risky – how often do we have to provide the “UNTESTED!!” caveat on how to use features we expose in the UI?)

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    It’s untested because I didn’t have the time to do that before running off to another meeting today 😉 Ran it on my test blog and it was fine, but I’d still make a good backup first.

    As you pointed out before:

    But the delete command is sent in the URL string, so you had better not delete so many that the web server rejects a string for being too long.

    You also should know that PHP commands take longer to run and use more memory than an SQL query. In the end, while you’re both asking for something perfectly reasonable and sensible, there isn’t a safe, elegant, and memory friendly way to code this in. AND it’s an obscure (rare) request, which means it will be rarely used, and many efficiency studies have proven than rarely executed code causes the most problems.

    This is plugin territory, I’m afraid, or manual work.

    Speaking of. Here’s a decent tutorial on how to run an SQL query via PHPmyAdmin: http://community.mybb.com/thread-4720.html

    I would think this would be a reasonably common request. I am currently facing it where i have thousands of posts from a blog I imported from Blogger. I want to remove all “uncategorized” tags as well as change all posts categorized as “uncategorized” to the category “NameOfMyBlog”.

    I know SQL but I’m VERY rusty and don’t trust myself at the moment. I’d really like it if someone had a more elegant solution. From a UI standpoint it would be really straightforward. Just use Gmail’s solution where you are asked with a checkbox if you’d like to select ALL posts.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    I want to remove all “uncategorized” tags as well as change all posts categorized as “uncategorized” to the category “NameOfMyBlog”.

    Why not just rename the category?

    Doesn’t uncategorized have some special properties? For instance if anything is not assigned it is automatically assigned to uncategorized. Would that now change to “NameOfMyBlog”?

    Anyway, it’s true doing this would help to some degree but it doesn’t 100% solve it. I’m surprised there isn’t another more elegant solution. If I don’t hear anything soon I guess I’ll try this approach.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    It is the default category, this is true. You have to have at least one.

    But if you don’t want anything uncategorized then it makes sense to replace it/rename it.

    Anyway. Select All is too server intensive via PHP to try to put that in core right now. Do them in chunks, do it via SQL, or rename it. Those are your best options.

    Ok thanks Ipstenu, i’ll give it a whirl.

    Oh dear. Didn’t work at all. A vast majority of the posts — although I can see now rhyme or reason to which ones fit this pattern — still say “uncategorized” as the post category even though there is no category by that name. Any thoughts?

    Ok well I do see the pattern now. The posts that have a tag of “MyBlogName” now are associated to the category of “MyBlogName” but the rest of the posts (over half) say they are of category “uncategorized” even though there is no category by that name anymore.

    If it has any bearing, the reason I have so many posts that have the “MyBlogName” as the tag may have been related to the import process I did from Blogger. I’m not sure. When the import is initially done all of the “tags” in Blogger are made into “categories” on the WordPress side. I used the Categories to Tags converter plugin.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    You can’t have a TAG and a CATEGORY with the same name… Which is probably where things went pear shaped here :/

    Maybe you’re right. I manually corrected everything now but it took well over an hour. That said my mouse clicking muscles got a very good workout. :^)

    Thanks for help. I’m considering this done from my perspective and will start getting more comfortable with the data model so that SQL based solutions don’t seem so daunting.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Suggestion: "Select all posts" for bulk actions/edit’ is closed to new replies.