Hi there,
I have some issues with displaying my CPT with a taxonomy on my page.
I have set up a CPT “spieler” with a taxonomy “manschaft”. Within the “manschaft”-taxonomy I have terms like “1-herren”, “2-herren”, “3-herren” and so on. The page names have the same slug-name as the terms. So my idea was to query with the slug name.
I tried to fetch date with the code but I did not work. I really appreciate any help.
<?php
$abfrage = array(
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
'no_found_rows' => true,
'update_post_term_cache' => false,
'update_post_meta_cache' => false,
'post_type' => 'spieler',
'taxonomy' => 'manschaft',
'field' => 'slug',
'term' => 'get_query_var( 'manschaft' )',
);
query_posts( $abfrage ); while ( have_posts() ) : the_post();
?>
<li><?php the_title(); ?></li>
<?php endwhile; wp_reset_query(); ?>
The result of this query is that all data is shown from the taxomomy, not only “1-herren”.
Not realy an ACF question. Aber vielleicht:
$terms = array('1-herren');
$abfrage = array(
'post_type' => 'spieler',
'tax_query' => array(
array(
'taxonomy' => 'manschaft',
'field' => 'slug',
'terms' => $terms,
),
),
);
https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters