Get Taxonomy and metadata
$terms = get_terms( ‘my_taxonomy’ ); if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ foreach ( $terms as $term ) { $all_term_meta=get_term_meta($term->term_id); } }
$terms = get_terms( ‘my_taxonomy’ ); if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ foreach ( $terms as $term ) { $all_term_meta=get_term_meta($term->term_id); } }
try with this function function get_posts_in_taxonomy($post_type, $taxonomy, $term_id, $include_children=false, $limit) { $args = [ ‘post_type’ => $post_type, ‘posts_per_page’ => $limit, ‘tax_query’ => [ [ ‘taxonomy’ => $taxonomy, ‘terms’ => $term_id, ‘include_children’ => $include_children ], ], // Rest of your arguments ]; $posts = new WP_Query( $args ); if($posts->have_posts()) { while($posts->have_posts()) { $posts->the_post(); //code todo here … Read more
There was some confusion in the original question with the terminology i used. I didn’t find a way to do what i was after but it’s to late for me to do it now.
Try taking out the ‘paged’ => $paged parameter, as it is simply returning the amount of results for that page, which seems to be set at 10. (You will need to do two separate queries – one for getting the true count, and one for displaying the posts in a paginated format.)
you need a semicolon at the end of your last line of code: echo $term_link;
I’ve recently developed a plugin that can support the custom taxonomy element of this problem. The plugin creates select boxes for each of your custom taxonomy terms and throws the results onto a custom results page (of your choosing): Advanced Custom Post Search It currently doesn’t support custom meta values if this is something you … Read more
I found the answer I was looking for as this: $sport_slug = get_query_var(‘term’);
If you are in term archive page, the taxonomy and term is actually set. You could hook wp_head to add the open graph in your functions.php: add_action( ‘wp_head’, ‘wpse_wp_head’ ); function wpse_wp_head () { //First, we check if we are in our custom taxonomy if( is_tax(‘my-custom-taxonomy’) ) { $taxonomy_slug = get_query_var( ‘taxonomy’ ); $term_slug = … Read more
This post is super old but I’ll post my solution here in case anyone else stumbles across this. If you’re using Yoast SEO you can hook into their existing implementation (they do this already for categories). function add_variety_primary_term_taxonomy( $taxonomies, $post_type, $all ) { if( $post_type == ‘product’ && isset( $all[‘my_custom_tax’] ) ) { $taxonomies[‘my_custom_tax’] = … Read more
The page not found error doesn’t mean that the template file is not found/used. Note that a URL returns a 404 status header (not found), then 404.php is used (or index.php if 404.php doesn’t exist). I think your real problem is that you have not flushed the rewrite rules after the taxonomy has been registered. … Read more