L
L
Leonid2020-05-07 16:32:32
Taxonomy
Leonid, 2020-05-07 16:32:32

Do mass re-order of WordPress posts in custom taxonomy (categories)?

There is a taxonomy of categories (> 700 items) in them WordPress custom posts (> 15,000 items)

Unfortunately, the posts in most of the categories were created in the wrong order (as they say: "upside down") and now you need them in these selected categories, turn over - make such a massive re-order (flip) and of course, in a programmatic way

, I did not find ready-made plugins for this - all re-order plugins are manual, and when 15 thousand is not an option.

What do you recommend? Maybe someone solved such a problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2020-05-07
@HeadOnFire

Well, if you need sorting "manually", then you will have to do it manually :)
In fact, you can cheat and partially automate or change programmatically, then manually fix only what needs attention.
First you need to understand how such a "manual" sorting is done in WP. By default, WP sorts by creation date, from newest to oldest. Theoretically, you can select all records by composing an arbitrary query with the desired sorting, loop through them and change the dates. Often, for custom post types, the date itself is meaningless (data doesn't age like posts for example) and there's nothing wrong with changing it.
The second option is to use sorting by menu_order ('orderby' => 'menu_order'). By default, the value is 0, you can run WP_Query in the same way with the desired sorting options for the current posts, then loop through the received posts and set the desired menu_order. This value is used by plugins for drag-n-drop sorting of posts in the admin area.
Well, yes, you can just use the desired sorting only in those places where you need it - if this is a global WP_Query, then through the pre_get_posts hook, isolating the necessary conditions, if this is a secondary loop - then simply through the order_by parameter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question