Home › Forums › Calendar Products › Events Calendar PRO › Tribe_get_events malfunctioning when using transients API
- This topic has 4 replies, 3 voices, and was last updated 8 years, 10 months ago by Support Droid.
-
AuthorPosts
-
May 21, 2012 at 3:31 am #19432JesseMember
When using the query as a transient variable as shown below (i.e. using get_transient), the query results are incorrect when compared to actually writing out the query. It does not honor the “upcoming” parameter.
Have you tested tribe_get_events with the transients API or am I doing something wrong? Is it possible that the plugin hasn’t fully initialized yet when admin_init is called?
thanks!
In functions.php in a function ( hooked into admin_init via add_action(‘admin_init’,’set_event_transients’; )
`$upcoming_events = tribe_get_events( array(
‘eventDisplay’ => ‘upcoming’,
‘posts_per_page’ => -1
));``if ( true === ( get_transient( ‘upcoming_events’ ) ) )
delete_transient( ‘upcoming_events’ );``set_transient( ‘upcoming_events’, $upcoming_events );`
In my template:
`$artist_events = $upcoming_events;`
`foreach ($artist_events as $post) :`May 21, 2012 at 11:00 am #19456JonahParticipantHey Jesse,
I’m not sure if this has been implemented or not but would you please post your code somewhere else so we can read it? http://postie.org / http://pastebin.com / http://gist.github.com
Thanks,
JonahMay 21, 2012 at 4:29 pm #19487JesseMemberHere’s the code:
https://gist.github.com/2765375thank you!
May 21, 2012 at 10:01 pm #19514JonahParticipantHey Jesse, not quite sure why your example is not working but I got transients to work this way: https://gist.github.com/2766720
I went off of this example for reference: http://www.wpbeginner.com/wp-tutorials/speed-up-your-wordpress-by-caching-custom-queries-using-transients-api/
So it appears to be working… Can you try refactoring your code based off of my example and let me know whether that works?
Thanks,
JonahJuly 7, 2015 at 6:20 am #976897Support DroidKeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Tribe_get_events malfunctioning when using transients API’ is closed to new replies.