how do you pull data from two taxonomies?

First, get all term slugs from the custom example taxonomy space by current post ID. $space_terms = wp_get_post_terms( $post->ID, ‘space’ ); if( $space_terms ) { $space_terms = array(); foreach( $space_terms as $term ) { $space_terms[] = $term->slug; } } You should specify the logical relationship between each inner taxonomy array when there is more than … Read more

How to appear plural or singular custom taxonomy name(-s) inside woocommerce single product meta php file

The final solution of plural and singular terms name is below. Code <?php $term_ids = wp_get_post_terms( $product->get_id(), ‘variety’, array(‘fields’ => ‘ids’) ); echo get_the_term_list( $product->get_id(), ‘variety’, ‘<span class=”posted_in”>’ . _n( ‘Ποικιλία:’, ‘Ποικιλίες:’, count( $term_ids ), ‘text-domain’ ) . ‘ ‘, ‘, ‘, ‘</span>’ ); ?> In my project is working correct 🙂 Hope to help … Read more

WP_Query not using custom taxonomy categories on custom post type

WP_Query only returns WP_Post objects for the results. To get the taxonomy terms for each post you need to use get_the_terms( $post, ‘recipe_categories’ ); for each post. This is because WP_Post represents each row of wp_posts, which does not include taxonomy information. The links between posts and terms is in the wp_term_relationships table.

How to associate custom taxonomy terms with custom post type?

$catids = $_POST[‘artticle_category’]; /* * If the ids are coming from the database or another source, we would * need to make sure these were integers or convert them to interger using intval: */ $catids = array_map( ‘intval’, $catids ); $catids = array_unique( $catids ); $taxonomy = ‘articles_category’; $post_id = ‘1’; $term_taxonomy_ids = wp_set_object_terms( $post_id, … Read more

Template taxonomy-{taxonomy}.php doesn’t show my posts

Well, first of all, you are not doing anything with the $term variable. You are querying it, but then it sits there, waiting to be picked up. Try this code in your taxonomy template, called taxonomy-hardware_category.php: // prepare the variables for the query $tax = get_query_var(‘taxonomy’); $term = get_query_var(‘term’); // Setup the loop, build the … Read more