The question:
I am trying to understand how the Admin Tables are populated (for posts, users, plugins…).
With Terms/Taxonomies I am confused. In the /wp-admin/edit-tags.php file everything is normal until we reach the $wp_list_table->prepare_items()
method (where an $args
is set up to later on go fetch data), but from there on I don’t understand where the actual database query takes place.
Looking at the WP Users List Table’s prepare_items()
method, it’s quite clear:
$wp_user_search = new WP_User_Query($args);
$this->items = $wp_user_search->get_results();
So I expected a similar approach for Terms, but looking at the WP Terms List Table class, you can find:
public function has_items(){
// todo: populate $this->items in prepare_items()
return true;
}
Which means that the items are loaded somewhere else. But where?
The Solutions:
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
Method 1
The items are loaded via get_terms()
(see source on Trac) in the display_rows_or_placeholder()
method which is called in the display()
method which is called in wp-admin/edit-tags.php
(see source on Trac). But the $items
property is never populated with the terms.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0