开发者 | mpol |
---|---|
更新时间 | 2024年11月28日 01:58 |
PHP版本: | 7.0 及以上 |
WordPress版本: | 6.7 |
版权: | GPLv2 or later |
/wp-content/plugins/
directory'orderby' => 'term_order', 'order' => 'ASC'
to manually sort queries by this order.Did you set the option for that taxonomy to use that custom order? Make sure to check it so the filters run with your taxonomy.
When you use default functions like get_terms or get_categories, this should not be needed. If you do need to, you can apply the sorting for the taxonomy by using: 'orderby' => 'term_order'.
This function only fetches the ID's of the terms, so it is impossible to sort them by term_order. If you do need the sort_order, use a function like get_terms with the 'child_of' parameter. That will fetch an array of WP_Term objects that can be sorted.
If it is a much used plugin, can you tell me what is the name for the taxonomy? In the customtaxorder_wp_get_object_terms_order_filter it needs to be added, and the get_terms filter should not run on that taxonomy. The tag_cloud_sort filter should do that. If it is a custom taxonomy, you can also use a filter:
There is a bug with the the_tags function, where it will sort according to the setting for categories. This happens in the 'customtaxorder_apply_order_filter' function where the $args has two taxonomies but only one orderby can be returned.
This plugin only supports sorting the attributes/terms. These are the items like S, M and L. For sorting the taxonomies like 'size', you need to sort them on Woo's attributes page. For Products Categories, you can change the order on Product > Categories. There’s a three-line icon next to each category, you can hold it and drag the category up or down to change the order.
For sorting the terms you need the manage_categories capability.
There is an admin page to sort them, and save them in the database. You can use a function to sort taxonomies themselves like this: name . ""; } ?> The function requires a parameter with an array of taxonomy objects.
'customtaxorder_update_order' is being run when saving the order of terms in the admin page. You could add the following example to your functions.php and work from there.
'customtaxorder_terms_ordered' action is being run after term array has been ordered with usort. Please be aware that this can be triggered multiple times during a request. You could add the following example to your functions.php and work from there.
'customtaxorder_settings' filter is being after fetching the settings for all taxonomies. You could add the following example to your functions.php and work from there.
In case the GET parameter 'orderby' is set it will be used to order terms, instead of posts, users, or anything else. Therefore when that GET parameter is set, there is no custom order applied in this plugin. You can add a filter to possible ignore the orderby parameter in the GET request. That might be useful if your GET parameter for orderby is used to sort posts, users, or just anything that is not terms. Example code for using the filter:
Translations can be added very easily through GlotPress. You can start translating strings there for your locale. They need to be validated though, so if there's no validator yet, and you want to apply for being validator, please post it on the support forum. I will make a request on make/polyglots to have you added as validator for this plugin/locale.
term_relationships
table.
this should fix some reported issues where the problem was unclear.