List posts of term on term’s admin edit page
On the tag page in admin, you can see the count column, that links to all the posts attached to this term Thanks to @Pooja Mistry for answering this
On the tag page in admin, you can see the count column, that links to all the posts attached to this term Thanks to @Pooja Mistry for answering this
I ended up using the wp_get_object_terms() function instead of get_the_terms(). The get_the_terms() function attempts to cache the terms where wp_get_object_terms() does not. The fixed code to get the hero images CPT’s ID is: $hero_image_id = ( $assigned_hero_images = wp_get_object_terms( $post_parent, ‘hero_images’ ) ) && ( $hero_image = array_shift( $assigned_hero_images ) ) && isset( $hero_image->term_id ) … Read more
Wait for WordPress 4.7 on 6th December. It has this almost built-in. If I got it right, then you’ll want to prevent some terms from deletion. I already made a snippet for that which works with WP 4.7 add_filter( ‘user_has_cap’, function ( $allcaps, $caps, $args ) { if ( ! isset( $args[0] ) || ‘delete_term’ … Read more
Taxonomy Single Term is a small library that helps to implemement this functionality. Usage Include the class.taxonomy-single-term.php file from within your plugin or theme Initialize the class (update the taxonomy slug with your own): $custom_tax_mb = new Taxonomy_Single_Term( ‘custom-tax-slug’ ); Optional The second parameter is an array of post_types and the third parameter is either … Read more
User gmazzap has a good explanation of Object Cache you may want to read over. If we take a look at get_terms() we can see it creates a new WP_Term_Query() and that classes get_terms() is where the potential caching happens. Line 666 specifically. Just a little further down we can see if it test if … Read more
To make your cpt archive page show a list of your parent terms you can create a template file in your theme with the name archive-{cpt_slug}.php. This file will automatically be picked up when your cpt archive is called. There instead of writing a loop to output the individual posts you fetch a list of … Read more
Thanks to @Milo I could fix it. The problem was, that the tags were not assigned to any post. display.php $tags = get_tags(array(‘hide_empty’ => false)); The hide_empty param do the trick.
WordPress allows for customization of the default URL rewrite behavior (/slug/term) with a rewrite arguments array passed to the register_taxonomy() function. By defining values for the slug or hierarchical keys in this array, the default URL structure can be altered to suit your needs. It may also be altered such that unexpected results are returned. … Read more
The filter uses the third parameter as an array that gets passed to get_terms(), which you’re already using to specify the taxonomy to query. Looking at the get_terms() documentation, you can see there’s a ‘number’ argument that you can pass to limit the number of terms returned. This is what you want to use. Your … Read more
You can’t use the_tags in the custom post type. You should use the_terms instead. So, you can use this function to get the tags: the_terms( get_the_ID(), ‘blog-tags’, ‘ and tagged under ‘, ‘, ‘);