I've got terms defined under a custom taxonomy. I want the terms to be pseudo-hierarchical, in that I want each term to be able to define a "parent" term that can be selected from a drop-down, but I do not want to use the other terms as the options (which is the default behavior). Instead of using the same list of terms as potential parents, I want to use a custom data source.
I see in the
wp-admin/edit-tag-form.php file, starting on line 165, the following code that generates the drop-down list of parent terms:
$dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'edit' ); wp_dropdown_categories($dropdown_args);
And based on the documentation for wp_dropdown_categories, it looks like I can set up a hook into get_terms and then, theoretically, make use of WP_Term_Query to write my own custom SQL. (Although based on that code, I'm thinking I actually need to hook into taxonomy_parent_dropdown_args instead.) In any case, my question is: how do I do this?
I'm still relatively new to plugin development, and I haven't found any concrete examples of someone overriding the resultset of
get_terms by using the
WP_Term_Query class to define a custom query. I'm actually thinking about using an entirely new table, created by my plugin.
For example, suppose I wanted to query something like:
SELECT id, name FROM custom_parent_table WHERE taxonomy = %s
How would I go about implementing this with
WP_Term_Query? (Or, if I'm off base and haven't got the right understanding of how these hooks and classes interact, how would I do it regardless?)