struggling with taxonomies and taxonomy terms
-
Hi people,
Im struggling with taxonomies and taxonomy terms not returning what im expecting.
this is my code:
<?php if( get_row_layout() == 'post_grid' ):?> <div class="post-grid"> <style> .post-grid { display: grid; gap: 2%; grid-template-columns: repeat(<?php the_sub_field('post_per_row'); ?>,minmax(0,1fr));}.single-item a img {width: 100%; height: <?php the_sub_field('post_image_height')?>; object-fit: cover;}</style> <?php $PostTypeChoice = get_sub_field('post_type_choice'); $PostsPerPage = get_sub_field('post_per_page'); $categoryTag = get_sub_field('category_tag'); $categoryTagTerm = get_sub_field('category_tag_term'); $postGridArgs = array( 'post_type' => $PostTypeChoice, 'posts_per_page' => $PostsPerPage, 'post_status' => 'publish', 'tax_query' => array( array( 'taxonomy' => $categoryTag, 'field' => 'name', 'terms' => $categoryTagTerm, 'operator' => 'IN' ) ) ); $postGridItems = new WP_Query($postGridArgs); while($postGridItems -> have_posts()): $postGridItems -> the_post(); ?> <div class="single-item"> <?php if(get_sub_field('with_image') == '1'):?><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('medium'); ?></a><?php endif;?><a href="<?php the_permalink(); ?>"><h2><?php the_title();?></h2></a><a href="<?php the_permalink(); ?>"><span>Read More..</span></a></div> </div> <?php endwhile; wp_reset_query(); ?> <?php endif; ?>
Im trying to create simple customisable post grid.
So
<?php echo (get_sub_field('category_tag_term'));?>
returns “New Cat, Uncategorised” exactly what i want.
BUT
echo $categoryTagTerm;
returns just the word “array” not what i want.so if im using this
$categoryTagTerm = get_sub_field('category_tag_term');
why are they not the same?
when you try loading the page linked above im just displaying what is in the variables using “echo” and “print_r”
im just so confused because the data i want is there, but its not working.
what am i doing wrong?
Help please!
The page I need help with: [log in to see the link]
- The topic ‘struggling with taxonomies and taxonomy terms’ is closed to new replies.