Outputting an array of term meta values in a custom WooCommerce tab?

For your author content display, instead of print_r($all_term_meta); try a foreach: foreach($all_term_meta as $meta) { return $meta[0]; } It’s possible you may need to use “echo” instead of “return” but try “return” first. To control whether or not there is an author tab, update your woo_new_product_tab function with the same condition: function woo_new_product_tab( $tabs ) … Read more

WordPress function to get term or post object by id

get_queried_object() will get the currently queried ‘thing’ from the main query as an object. That could be a WP_Post, WP_Term, or WP_Post_Type (for post type archives) object, but I don’t think that’s quite what you’re asking for and wouldn’t be useful in AJAX. Other than that there isn’t a function for exactly what you’re asking … Read more

Ordering terms before displaying posts

You could use tax_query to get only the posts with the term that is currently being looped. $argsPost = [ ‘post_type’ => ‘meal’,//CPT meal ‘posts_per_page’ => -1, ‘meta_key’ => ‘ordre’, ‘orderby’ => ‘meta_value’, // Use the custom post order ‘order’ => ‘ASC’ ‘tax_query’ => array( array( ‘taxonomy’ => ‘cat_meal’, ‘field’ => ‘term_id’, ‘terms’ => $term->term_id, … Read more