How to filter custom taxonomy term name, slug, and description?

The default fields name, slug and description are not term metadata, so you should instead use wp_update_term() to update those fields. So just replace those three add_term_meta() with: wp_update_term( $term_id, ‘codes’, [ ‘name’ => $name, ‘slug’ => $slug, ‘description’ => $desc, ] ); Additionally, instead of using $_POST, I would use get_term() to get the … Read more

Can’t fetch Custom Post Type Data through Custom Query

Changing my query to following worked for me. I removed the product ID field & called the post taxonomy directly as I didn’t need the product Id’s. <?php $args = array( ‘post_type’ => ‘colorshades’, ‘fields’ => ‘ids’, ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘colors_product_id’, // ‘value’ => $product->id, // ‘compare’ => ‘=’, … Read more

Tax Query only returns for the first of several terms

Related issue: Multiple relationship for multiple tax_query in WP_Query The issue here was that mixed multi-relationship lookups are only permitted using the term_taxonomy_ids field in the query, the above worked fine once switched like so: $params = [ “status” => “publish”, “tax_query” => [ [ “taxonomy” => “jewellery_metal”, “field” => “term_taxonomy_id”, “terms” => [ 36, … Read more

Template for custom post type when taxonomy is in the URL

Your taxonomy’s rewrite base is actually book_types (see the “rewrite” => [ ‘slug’ => ‘book_types’, ‘with_front’ => true, ] in your code), so the taxonomy archive pages are accessible at the /book_types/<term slug> path.. and not /books/<term slug>. So it’s normal if /books/fiction shows a 404 error page, unless of course if there’s a post … Read more

Check If Taxonomy A and Taxonomy B has same Slug, 301 Auto Redirect Tax A to Tax B if True in WordPress

Try this, which should work, and if necessary, replace the artist on the 5th line below with the correct taxonomy slug: add_action( ‘template_redirect’, ‘my_301_redirect_tag_to_artist’ ); function my_301_redirect_tag_to_artist() { if ( is_tag() ) { // Check if an “artist” term exists with the same slug as the current tag. $artist = term_exists( get_queried_object()->slug, ‘artist’ ); if … Read more