Load a certain functions file for a certain taxonomy

I think there’s three things going on with your code. The first is that you’re passing a numeric string as the first parameter to has_term(). If you’re trying to pass the term ID to the function, you should remove the quotes from ’16’ and just pass 16, i.e. as integer. https://developer.wordpress.org/reference/functions/has_term/ The second is that … Read more

Multiple Custom Taxonomy Dropdowns Lists

The “dropdown” element declared and used in each of these functions is the same, so the last one is overriding all previous. Specifying different terms each time fixes the problem: var writerdropdown = document.getElementById(“writers”); function onWriterChange() { if ( writerdropdown.options[writerdropdown.selectedIndex].value != -1 ) { location.href = “<?php echo home_url();?>/writer/”+writerdropdown.options[writerdropdown.selectedIndex].value+”/”; } } writerdropdown.onchange = onWriterChange; var … 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

Set term on an attachment using wp_set_object_terms and want to display the full term text but it’s showing a slug instead

When a visitor fills out the email address field with “[email protected]”, what is displayed on the Attachment details screen (as in siteurl.com/wp-admin/upload.php?item=xx ) for that email field is “nameemail-com”. Yes, and that is the default behavior, i.e. WordPress displays the term slug instead of name (or the actual email address in your case). But there’s … Read more

Take a custom taxonomy value and save as a standard Product Tag

Got it worked out, working code as follows: function action_save_product_data( $post_id ) { if ( ‘product’ !== $post->post_type ) { $terms = wp_get_post_terms( $post_id, ‘product_brand’, array( ‘fields’ => ‘all’ ) ); if ( $terms ) { $prod_brand = $terms[0]->slug; wp_set_object_terms( $post_id, $prod_brand, ‘product_tag’, true ); } } }