Custom taxonomy displayed in search results
Custom taxonomy displayed in search results
Custom taxonomy displayed in search results
on the $args (used on your sidebar file), add another parameter – ‘hide_empty’ => false. Using wp_list_categories() doesn’t not display terms which doesn’t have at least one post type object assigned with it. ‘hide_empty’ => false force it to display all of the terms.
I think the simple answer based on my testing locally is to change the value from true to false in this line of code which is included when you register taxonomy support for custom post types. ‘show_ui’ => false, Here’s the full code i used: add_action( ‘init’, ‘executive_type_taxonomy’ ); function executive_type_taxonomy() { register_taxonomy( ‘portfolio-type’, ‘portfolio’, … Read more
Turns out this does work as intended, I just got the taxonomy slug wrong. Oh well, hope this helps someone in the future.
You could use has_term Codex, like the following code: if( has_term( ‘jazz’, ‘genre’ ) ) { echo ‘This is something…’; } Remember to add the third parameter – $post (int or object), if it’s not in the loop.
To have the first code block to work on a secondary query, you’d need: function customize_customtaxonomy_query ( $query ) { $query->set(‘post_type’, array(‘business’) ); // return $query; // not necessary; actions do not return anything } add_action( ‘pre_get_posts’, ‘customize_customtaxonomy_query’ ); $q = new WP_Query($args); And you should remove it afterwards so that it doesn’t interfere with … Read more
Using has_term() requires the name of the taxonomy as a parameter. References: has_term() does not return when term is assigned post? Function Reference/has term
How to create default categories in new installs?
It looks like you’re trying to use get_terms() in the same way that you would use WP_Query() which you can’t do. ‘paged’ => $per_page This is not a valid argument to pass to get_terms() Also each post type has a rewrite rule to allow for pagination e.g. /2/, however that’s not the same with terms, … Read more
tl;dr; This is not possible with tax_query. A tax_query is a restriction of the results delivered, not used to order posts. You use the Order & Orderby Parameters for that. A little excursion into statistics This has to do with statistics and mathematics, as a taxonomy is a nominal scale, meaning it is just a … Read more