So I have an array that I’m working with. I’ve typed it out the array so that you can see it. $VideoCategorys
The array will be providing some values like shown here.
<?php $VideoCategorys = array("Stretching Videos", "jumping videos", "running videos"); ?>These values are WordPress category names that are being entered into sub fields of an ACF repeater
Anyways I need to use these values in a foreach loop like so
<?php
//Now I'd like to do a for loop in which I get the value for each array
foreach ($VideoCategorys as $Category) {
query_posts('category_name=$Category');
if ( have_posts() ) :
echo '<h2>'; echo $Category; echo '<h2>';
while ( have_posts() )
: the_post();
echo '<p>'; the_title(); echo '<p>';
endwhile;
else: echo '<h2>'; echo 'Nothing in the array'; echo '<h2>';
endif;
wp_reset_query();
}
?>
<?php wp_reset_query(); ?>
I feel like it’s the above code is right but nothing gets displayed. I double checked it and the WordPress loop is fine. I confirmed it by manually entering the category into the query and it work just fine
<?php query_posts('category_name=Stretching Videos,show_posts=-1'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
ANY IDEAS OF WHAT I CAN CHANGE?