Slow wp_term_relationships query

Prepare yourself for an unsatisfying answer… After several days of testing, the conclusion that I’ve come to is that, put simply, this isn’t WordPress’ “fault”. I believe another related issue on the server was putting undue strain on the system. This was simply one of the slower queries, which, since the server was under strain, … Read more

What is the difference between terms and tags?

Simple yet tough question, taxonomies are just groups of categories, while terms are just single categories within these groups.* So, for example, if you create a new post and choose category for it – the category itself is a term, and opening YourWordpressURL/wp-admin/edit-tags.php?taxonomy=category you’re going to see all the categories (taxonomy). Terms and Tags are … Read more

WordPress 4.4+ breaks Walker Extension

Your original solution was a hack, and no surprise it failed. In general never add methods/attributes to objects that you do not control their class and future development. The right way is to create your own object to be passed to the walker. Pass to it the category object on construction and either populate fields … Read more

Get second level terms of custom taxonomy

You can use PHP’s array_filter to process the results of a taxonomy query function that returns its results, and then display them. Something like: # This returns the whole taxonomy… $whole_tax = get_terms(‘customtax’, array(‘hide_empty’ => 0)); $second_level = array_filter($whole_tax, function ($t) { # This term has a parent, but its parent does not. return $t->parent … Read more

Creating a non-removable taxonomy term

Update Indeed, there is a way to define one term per taxonomy as default term which makes it non-deletable from the admin GUI. WP_Terms_List_Table looks for an option get_option( ‘default_’ . $this->screen->taxonomy ). So if you have a custom Taxonomy called genre, you have to set an option default_genre with the term-id of the term … Read more

How to limit the number of terms (terms acts like categories)

number (integer) The maximum number of terms to return. Default is to return them all. http://codex.wordpress.org/Function_Reference/get_terms So… $terms = get_terms(‘new_category’,array(‘number’ => 5)); But there is a good chance that some of your terms will never show up. You will get the first five or the last five (in the example) depending on the sort order. … Read more