`get_terms()` with `child_of` and `childless` combined

OK, so this is what I came up with: function get_childless_term_children( $parent_id, $taxonomy ) { // get all childless $terms of this $taxonomy $terms = get_terms(array( ‘taxonomy’ => $taxonomy, ‘childless’ => true, )); foreach( $terms as $key => $term ) { // remove $terms that aren’t descendants (= children) of $parent_id if( !in_array( $parent_id, get_ancestors( … Read more

Taxonomy term page going to 404

Following @CraigWayne’s suggestion to use Query Monitor… Message: “Use of undefined constant term_name – assumed ‘term_name’”. Count: 1. Location: wp-content/themes/elegant/taxonomy-source.php:38. Caller: wp-includes/template-loader.php wp-includes/template-loader.php:74. Component: Core. >>>>> Line 38 in taxonomy-source.php included “” it was objecting to term_name in my taxonomy-source theme file; I changed it to $term = get_queried_object(); followed by name; ?> The takeaway … Read more

Rename a slug label

As SallyCJ mentioned, gettext is really the only option you have with this, because the Slug labels are hardcoded in the Core of WordPress. https://core.trac.wordpress.org/browser/tags/5.2/src/wp-admin/edit-tags.php#L439 Here is a snippet I wrote and tested that should work for you, and it will only run on the backend and only on the two pages where you will … Read more

List taxonomy term slugs within shortcode (do_shortcode)

The do_shortcode() function is currently in the foreach loop. I don’t know what are the parameters of this shortcode , but if it accepts comma separated values of term slugs: $terms = get_the_terms( $post->ID , ‘shoptype’ ); $i=1; $commaSeparatedvalues=””; foreach ( $terms as $term ) { $term_link = get_term_link( $term, ‘shoptype’ ); if( is_wp_error( $term_link … Read more

Custom Taxonomy Is Being Pulled into a Page, But It Doesn’t Have A Hyperlink

@Chewy you can try below code snippet. <p class=”cat”> <?php $terms = get_the_terms($post->ID, ‘news_categories’); foreach ($terms as $term) { $term_id = $term->term_id; $term_name = $term->name; $term_link = get_term_link( $term_id ); echo “<a href=””.$term_link.””>”.$term_name.”</a>”; } ?> </p> please chcek and let me know if this work or not. if not then please ping me I will … Read more

Enable taxonomies by post type in an array of CPTs

I have tweaked theyour code and it should work.. please give it a try add_action(‘init’, ‘all_custom_post_types’); function all_custom_post_types() { $types = array( array(‘the_type’ => ‘event’, ‘single’ => ‘Event’, ‘plural’ => ‘Events’ ), array(‘the_type’ => ‘resource’, ‘single’ => ‘Resource’, ‘plural’ => ‘Resources’ ), array(‘the_type’ => ‘team’, ‘single’ => ‘Team’, ‘plural’ => ‘Team’ ), ); foreach ($types … Read more