Hi Marcus (or anyone who wants to help 😉 )
I need help to solve an issue in the best possible way. Once I have done it, I promise I’ll share the code with everyone as it will be quite useful.
I’m using Events Manager and Alo Easymail Newsletter. This newsletter plugin allows to automatically retrieve and insert a list of Posts in the newsletter. I want to insert a list of Events instead, so I need to replicate that functionality.
The way it works is with custom hooks (it has a file called alo-easymail_custom-hooks.php). Here it is possible to define a function to print the Events within the newsletter. That should not be a problem. The following code works:
$args = …;
$events = EM_Events::get($args);
if ( $events ) :
foreach( $events as $event ) :
My problem is that that function print_event($event) I don’t want to re-do it, I want to use the same function defined as the tapestry for the Archive, so it has that same format when going to the Events List page.
However this function works inside the loop, so I can’t reuse it if getting the events through EM_Events::get(), since this function already retrieves a list of Events in an array.
My question is: is it possible to execute a function which will init the loop with the needed conditions (limit, scope, category, etc), but not retrieve the Events as yet? That way, I can later execute the tapestry callback function and print the Events from within the loop.
Thanks for the help!
I’m not sure what you mean by tapestryl
if you want to use the loop, you can use WP_Query as well to create a loop. You’d search for the event post_type and maybe you’d want to add a custom field search for the meta field _start_ts which is a timestamp of the start date, so you get your events cronologically ordered.
more on that here –
- The topic ‘load Events in the loop to insert in Newsletter (Alo Easymail)’ is closed to new replies.