Custom Taxonomies Terms as Post Title for Custom Post Types upon Publishing

I’ve pieced together a solution. Let me know if it’s what you need: add_filter(‘the_title’,’term_filter’,10,2); function term_filter($title, $post) { $post = get_post($post) ; if($post->post_type === ‘special_post_type’) { $terms = wp_get_object_terms($post->ID, ‘taxonomy’); if(!is_wp_error($terms) && !empty($terms)) { $title = $terms[0]->name; } } return $title; } Basically, I’m using a filter for the title that checks what post type … Read more

Return only the custom sub-term for custom post type, do not echo term-parent

Here’s more of a complete guide based on the $wp_query object: The Taxonomy First you might want to know in which taxonomy you are, what its name is and retrieve all its available data from the object. // Taxonomy name $taxonomy = get_query_var( ‘taxonomy’ ); // Taxonomy object get_taxonomy( $taxonomy ); // Taxonomy name get_taxonomy( … Read more

same taxonomy for several post types: how to hide empty in a specific post type?

Thanks to this answer, I was able to see the light. Here is how to query taxonomy terms related to (woocommerce) products that are “in stock”. It uses both tax_query (to relate product to taxonomy) and meta_query (to filter out out-of-stock products). $artists = get_terms_by_post_type( array(‘artist’), array(‘product’)); if( !empty($artists) && !is_wp_error( $artists ) ){ // … Read more

Exclude Child Terms From Parent Posts

In your get_terms() call, try setting the hierarchical option to false: $children_terms = get_terms($taxonomy, array( ‘parent’ => get_term_by(‘slug’, $parent_term, $taxonomy)->term_id, ‘hierarchical’ => false )); This option normally defaults to true, which is probably why you’re getting the extra copies.

Is there a filter/action to add content to WP admin metaboxes?

I couldn’t find a hook so I went with the JS option. add_action( “admin_head-post-new.php”, ‘meta_box_instruction’ ); //new post add_action( “admin_head-post.php”, ‘meta_box_instruction’ ); //edit post function meta_box_instruction($d) { global $post; if($post->post_type == ‘{YOUR POST TYPE}’ || $_GET[‘post_type’] == ‘{YOUR POST TYPE}’): ?> <script type=”text/javascript”> jQuery(document).ready(function(){ jQuery(‘<p>Some instruction</p>’).insertBefore(‘#taxonomy-{YOUR TAXONOMY NAME}’).parent(); }); </script> <?php endif; }

How are terms connected with posts in database?

The posts are related to taxonomies (taxonomy/tag) in the wp_3_term_relationships table, where the object_id column is the post’s id, and the term_taxonomy_id is the taxonomy/tag id. Depending on what you want to accomplish, the solution might be to create the same taxonomies at each blog. This way the tax_query should work as normal.