Custom Template for one Taxonomy Term

That’s easy, instead of trying to change which template gets loaded, load the single-grants.php template, then use get_template_part inside it, and pass different values based on the terms the post has. Be careful though, single-termname.php is not a good naming scheme, as it could be abused, e.g. you could encounter clashes. It would be better … Read more

Clone Terms of one taxonomy to another

Could you not just keep the same taxonomy and declare it on both CPTs?? That way both would inherit the same terms, at the same IDs, which would allow you to get posts from both CPTs if required. At your CPT creation, you can tell it which Taxonomies to use by setting a parameter of: … Read more

Group child category IDs based on their parent category

The quick take would be something like this: $categories = [ ]; $parent_categories = get_categories( [ ‘parent’ => 0 ] ); foreach ( $parent_categories as $parent_category ) { $id = $parent_category->term_id; $categories[ $id ] = wp_list_pluck( get_categories( [ ‘parent’ => $id ] ), ‘term_id’ ); } The important bit is a parent argument, which limits … Read more

Question with get_the_term_list

You could use get_terms() and loop through it – using the term description as the “short name” and slug as the specific class ( or you could use an array of colors of your choice ). Let’s look at a quick example: <?php $terms = wp_get_post_terms( $post_id, ‘category’ ); if( ! empty( $terms ) ) … Read more

Does get_terms() use any sort of caching on its query?

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

get_terms ‘number’ parameter does not appear to work

So here’s some info for any other people with this issue. get_terms will not use the number parameter under certain conditions, such as if you pass in a parent parameter or if the hierarchical parameter is true. In these cases I have tried two workarounds, neither very good. You can call get_terms then do an … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)