// MOVED THIS QUERY OUTSIDE THE LOOP AND IT WORKED
// TODO: GET THIS AS A UNIQUE FUNCITON I CAN CALL
// saving the original / existing wordpress query
$temp_query = clone $wp_query;
// What we're doing is looking for featured events that are also recurring events
// Then excluding those recurring events
// if you just want to exclude recurring events , you could remove the noted section
$pagesorter = array(
// if you wanted to further filter by a specific tag
// I don't so its commented out but you may need it
//'tag' => 'resource',
'post_type' => 'event',
'tax_query' => array(
// START OPTIONAL
// If you want recurring events that are ALSO Featured Events
// Then just remove the slash star /**/
/*
'relation' => 'AND',
array(
'taxonomy' => 'event-categories',
// you could list more than one term here as follows
//'terms' => array( 'featured-events', 'comedy' )
// I only need the one I want to include
'terms' => array( 'featured-events'),
'field' => 'slug',
'operator' => 'IN'
),
*/
// END OPTIONAL
// note how tax_query MUST BE a nested array
// ie. "array( array("
array(
'taxonomy' => 'event-categories',
// you need to have an Event Category with the slug "recurring-events"
// then you need to edit your recurring events to add this term
'terms' => array( 'recurring-events'),
'field' => 'slug',
'operator' => 'NOT IN'
)
),
'posts_per_page' => -1,
'paged' => $paged,
);
// lets run a new Query
// to do this you would need this code to be outside the main loop
$customPosts = new WP_Query($pagesorter);
$cat_post_ids = array();
// starting loop
while ($customPosts->have_posts()) : $customPosts->the_post();
// some optional tests to make sure we're returning the correct data
//$count++;
//echo 'count'.$count; // lets get a count of how many posts get returned
// echo '+ + + ID'.get_the_ID().'- - -'; // lets see the id of each returned post
//the_title(); // lets see the title of each returned post
array_push($cat_post_ids, $post->ID);
endwhile;
// optional test - lets see if we get the array we wanted.
//print_r($cat_post_ids);
// restoring the original query so it can be later used to display our posts
$wp_query = clone $temp_query;