[wp-trac] [WordPress Trac] #35925: Filter for wp_get_object_terms() arguments
WordPress Trac
noreply at wordpress.org
Tue Feb 23 18:55:43 UTC 2016
#35925: Filter for wp_get_object_terms() arguments
-------------------------------+-----------------------------
Reporter: enrico.sorcinelli | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: trunk
Severity: normal | Keywords:
Focuses: |
-------------------------------+-----------------------------
The following suggested patch adds a new `wp_get_object_terms_args` filter
in `wp_get_object_terms()` function in order to filter the arguments in
retrieving the terms associated to the post. For example:
{{{#!php
add_filter( 'wp_get_object_terms_args', 'wp_get_object_terms_args_hook',
10, 3 );
function wp_get_object_terms_args_hook ( $args, $object_ids, $taxonomies )
{
$args['orderby'] = 'term_order';
return $args;
}
}}}
`wp_get_object_terms()` is widely used to retrieve terms taxonomies but
it's not possibile to set the `term_order` as orderby clause everywhere in
a simple manner:
- The posts list
Even if in the post list (''wp-includes/category-template.php'') you can
uses `get_the_terms` filter to get ordered terms, you have to write
additional code
- The metabox taxonomy (advanced edit)
It seems that there is no filter/hook that allow to set the `term_order`
as orderby for terms to edit (the `terms_to_edit` filter in ''wp-
admin/includes/taxonomy.php'' seems to come too late :-( )
- The XML-RCP interface
The patch filter will be used in `wp_getPost()` XML-RPC interface method
by returning ordered terms
Comments and suggestion are appreciated
Kindest regards
PS1: Alternatively, with the `get_object_terms` filter you can do the
orderby (among all other arguments) at the price to loose all the logic
inside `wp_get_object_terms()` so you have to rebuild the terms array from
scratch.
PS2: The attached patch can be applied to 4.4.2 version too.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35925>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list