Match and Merge Terms in Different Taxonomies

Grab all the post tags and loop over them. If it’s deemed an “author” by a pattern match, check to see if the equivalent author_tax term exists. If not, create it. Now you can build two stacks: one for author_tax terms to append to the post, and another for post_tag‘s to be removed. $post_tags = … Read more

CTP – check for value inside objects

There’s no need for two loops. Just iterate over the terms and use in_array(): foreach ( $terms as $term ) { if ( in_array( $term->slug, $months ) { echo ‘yes’; else echo ‘no’; } }

Custom term templates

If you look at the template hierarchy, you need to create a template taxonomy-{$taxonomy}-{$term}.php. In your case, that template will be called taxonomy-product_cat-awesome.php where I assumed the slug of your term is awesome Just a tip, the “categories” of a custom taxonomy is called terms. The build in taxonomy category “categories” is also called terms, … Read more

Getting Category Children

The child_of parameter excepts an integer value of the specific term you need to get descendants from. This means that you need to get the ID from the On-going category term and then passing that ID to the child_of parameter. To note, the child_of parameter returns all descendants of the term passed, this includes direct … Read more

Default post_tag for custom post type

To set the taxonomy post_tag to your custom post type, you need to set the taxonomies parameter in your arguments when registering your post type taxonomies (array) (optional) An array of registered taxonomies like category or post_tag that will be used with this post type. This can be used in lieu of calling register_taxonomy_for_object_type() directly. … Read more

Echo taxonomy name – second level

You can use that code to retrieve the last taxonomy term in your taxonomy list: in your functions.php file create a custom function: function my_custom_function() { global $post; $terms = get_the_terms( $post->ID, ‘location’ ); if (!empty($terms)) { foreach($terms as $term) { if (!get_term_children($term->term_id, ‘location’)) { echo $term->name; } } } } When, inside your archive.php … Read more