Hi all, I am trying to display all posts with certain categories on their corresponding pages. Iv’e set up the categories under WP posts and added a taxonomy field to the new custom post template.
Here’s what I have so far:
$post_type = 'post';
$taxonomy = 'graphic_assets'; # the post category to query
$terms = get_field('asset_cat'); # the taxonomy field set up for each new post
foreach ($terms as $term) :
$args = array(
'post_type' => $post_type,
'posts_per_page' => -1,
'tax_query' => array(
'taxonomy' => $taxonomy,
'terms' => $term,
$posts = new WP_Query($args);
<!-- img here -->
<?php the_field('assets_title'); ?>
<?php if (get_field('asset_file')) : ?>
<a href="<?php the_field('asset_file'); ?> ">
<?php endif; ?>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
Everything needs to be inside the ‘lt-inner’ div but i’m not sure where i’m going wrong. And i’m trying to query the post category with slug of ‘graphic_assets’. And then i obviously want that to repeat all the posts with that category and their custom fields.
I’d like to think i’m close to fixing it, but any help is appreciated. Thanks.
I realised I was missing the wp loop for posts duh