Home › Forums › Back End › (RESOLVED) :: Isolating catagory children and filtering using meta values
- This topic is empty.
-
AuthorPosts
-
November 17, 2010 at 4:42 pm #30722mrkingMember
This is long so bear with it… :)
I am so happy I found this site… I had someone help me with this code but even he doesn’t know why it isn’t working. I have been working through it and understand 80% of it… I’m getting there.
site: http://www.pleinairbc.com/event-listings/
I have some code to help filter posted events based on location name which are defined as sub categories under the main category ‘location’ (id 35). The location name in the drop box to the right should only display if the end date of the event is the same or less than todays date (the end date is defined as a custom field called ‘endDate’. The end date is defined in the ‘custom field’ area when posting via worpress 3.x as the variable ‘endDate’ looking like 2010/10/08 (Y,m,d)
All location names (Langley, West Vancouver, etc) are parented to the category ‘location’.
The issue is that two ‘locations’ (Langley and Salt Spring Island) for events are showing up in the drop down list which endDate has have come and gone. These two locations should not be showing in the list.
The resulting list that is being displayed on the screen after the drop down menus is correct. There are only two events currently that has an endDate later than todays date.
My issue is with the Location drop down not filtering correctly based on date.
My code is below. Please help me out.
=meta_value= '.$todaysDate.' &orderby=meta_value&order=ASC');
$the_post_cats = array();
if (have_posts()) : while (have_posts()) : the_post();
$the_post_cats = array_merge($the_post_cats, wp_get_post_categories($post->ID));
?>
term_id.'">';
$option .= $cat->cat_name;
$option .= '';
if(!in_array($cat->term_id , $the_post_cats)) echo $option;
// no idea what "if(!in_array" means compared with "if(in_array"
}
?>
Any help would be greatly appreciated.
Michael
November 18, 2010 at 12:36 am #74750mrkingMemberWell, we can close this one.
Embarrassingly it was a missing ‘&’
query_posts(‘cat=12,13,52&meta_key=endDate&meta_compare=>=meta_value= ‘.$todaysDate.’ &orderby=meta_value&order=ASC’);should have been
query_posts(‘cat=12,13,52&meta_key=endDate&meta_compare=>=&meta_value= ‘.$todaysDate.’ &orderby=meta_value&order=ASC’);
Three months on a single ‘&’ symbolHope this some how helps someone else. :)
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.