get_term_link() returns incorrect url

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

Update post terms with custom taxonomy

Yes it is. But you have to know the exact taxonomy’s slug, since colors are not like preserved terms to be generated programmatically. Here is an example of how to do it: // run our function when a post is published add_action(‘save_post’,’update_my_taxonomies’); function update_my_taxonomies($post_id){ // Check if the post has a particular taxonomy if(has_term( ‘blue’, … Read more

Querying on multiple taxonomies pulled from $_GET checkbox array not working?

Here: $search_values[‘tax_query’] = array ( You’re resetting the value of tax_query for every item in the foreach loop. It’s also being set to an invalid value: Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays). This construct allows you to query multiple taxonomies by using the relation … 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

Avoid duplicate post from same Taxonomy

I see two ways to go about it, both quite similar. A) You can collect IDs of displayed posts in an array and then exclude those with post__not_in query parameter like so: $years_loop = get_terms( array( ‘taxonomy’ => ‘works_year’, ‘orderby’ => ‘slug’, ‘order’ => ‘DESC’, ) ); // array for displayed posts, we will update … Read more