i have a problem and can't find a solution.
I would like to query in the normal Wordpress archive loop whether a certain meta key is available.
This works with the following code, but then it shows me all posts with the meta key from all categories.
I would like to have all posts with a certain meta key from the current category.
Can someone help me where is the problem?
A heartfelt thank you!
<?php
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'meta_query' => array(
array(
'relation' => 'OR',
array(
'key' => 'kategorie_art',
'value' => 'Material',
'compare' => '='
),
),
)
);
$query = new WP_Query($args);
while($query -> have_posts()) : $query -> the_post();
get_template_part( 'template-parts/content', get_post_type() );
endwhile; wp_reset_query(); ?>
I've also tried querying it with tags but that doesn't work.
<?php if ( have_posts() && is_tag('Material') ) : ?>
<?php
/* Start the Loop */
while ( have_posts() ) :
the_post();
/*
* Include the Post-Type-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Type name) and that will be used instead.
*/
get_template_part( 'template-parts/content', get_post_type() );
endwhile;
the_posts_navigation();
else :
get_template_part( 'template-parts/content', 'none' );
endif;
?>