thegreyspot
Forum Replies Created
-
Thats what the “N;” is… no idea what that means! haha
[Moderator Note: No bumping, thank you.]
Yes I have tested that too.
function getEventsWithFilter($limit, $conditions, $blog = ""){ $grab = 5; $offset = 0; $events = []; while(count($events) < $limit){ $tempEvents = EM_Events::get( array('limit' => $grab, 'offset'=> $offset, 'blog' => $blog, 'array'=> true)); if(count($tempEvents) == 0) break;//no more events to save //print_r($tempEvents); foreach($tempEvents as $tempEvent){ $EA = serialize($tempEvent->event_attributes); print_r($EA); if($EA){ foreach($conditions as $condition){ //echo $condition; if(in_array("publish_to_university_homepage", $EA)) array_push($events, $tempEvent); } } } $offset += $grab; } //Trim off extra arrays, since we do 2 at a time return array_slice($events, 0, $limit); }
Gives this as output (repeated multiple times):
N; Warning: in_array() expects parameter 2 to be array, string given in /Users/thegreyspot/Workroom/wnmu/wp-content/themes/wnmu/lib/custom.php on line 166
function getEventsWithFilter($limit, $conditions, $blog = ""){ $grab = 5; $offset = 0; $events = []; while(count($events) < $limit){ $tempEvents = EM_Events::get( array('limit' => $grab, 'offset'=> $offset, 'blog' => $blog, 'array'=> true)); if(count($tempEvents) == 0) break;//no more events to save //print_r($tempEvents); foreach($tempEvents as $tempEvent){ $EA = serialize($tempEvent['event_attributes']); print_r($EA); if($EA){ foreach($conditions as $condition){ //echo $condition; if(in_array("publish_to_university_homepage", $EA)) array_push($events, $tempEvent); } } } $offset += $grab; } //Trim off extra arrays, since we do 2 at a time return array_slice($events, 0, $limit); }
This gives me this error on the in_array line:
Warning: in_array() expects parameter 2 to be array, string given in
Also the print_r, clearly looks like an string.
Does that help? Thanks
@angelo_nwl I did that but in_array complains that its still a string. So I’m guessing it was able to serialize?
I mean, this doesnt look very normal to me:
[event_attributes] => a:1:{s:30:”publish_to_university_homepage”;s:1:”0″;}I am trying to do what Angelo_nwl suggested. However, I don’t know how to parse
[event_attributes] => a:1:{s:30:"publish_to_university_homepage";s:1:"0";}
Which is what is in my EM_Events array. PHP thinks its a string, so I can’t use in_array…
Any ideas?
Right thats what I understood too? But I’m saying that wouldn’t be very efficient. Do you have any recommendations on how I should do my search? Should I just go day by day until i have the number of events I want?
You mean grab a couple of events and then filter through them with this kind of if statement?
That would be sort inconvenient, because I wont know how many posts to grab before finding what i need.
Thanks
It just lists all of events and ignores the “publish_to_university_homepage =>1” attribute i have in my get() request.
Keep in mind, I added this custom field using Advanced Custom Fields (ACF), and NOT the events Manager custom fields. I did this because it made it easier with the other fields I have for posts. Do I need to use the Events Manager custom fields? If so, how would I form the get requests in this case? And can I apply the same custom fields across my whole multisite network?
Thanks
That worked!!! Thanks so much ?? +1! I should have just tried it…
Hmm not sure what you mean? I have a feeling the plugin only supports one blog io for that blog variable… anyone else know the answer to this?
Yes I have tried:
$events= EM_Events::get('limit=3&blog="2,3"');
As for your array parameter – you have a syntax error. That same syntax error might be why the blogs parameter isn’t working for you.
Maybe you can tell me what the syntax error is? I don’t see it.
Thanks
Ummm, thats what I have?
*bump ??
Forum: Fixing WordPress
In reply to: PageofPost setup getting Fatal Error in query.phpThanks webjunk. I was able to figure out that the Events Calendar plugin i had was giving issues. I really like that plugin so now I dont know what to do ??
Thanks for your help
Forum: Fixing WordPress
In reply to: PageofPost setup getting Fatal Error in query.phpOH no! I hope you get better ??
I switched the theme to the default theme, but seem to be having the same problem…
Can you give me any advice on how to find the culprit function?
thanks!