Hi there,
can you tell me which is the best way to get the Events List (eo-loop-events.php) via an ajax call to load it dynamically? I am despairing since hours. Would be very nice if you could give me a hint.
Thank you very much.
Tarek
Tarek Schneider
Hi Tarek,
The event list template is more for rendering, but you can try the following:
//Add a callback to your ajax hook - this will depend on your action variable
add_action( 'wp_ajax...ajax-hook', function() {
//Set the query based on your ajax request
$query = query_posts( ... ); //set the query
//loads the template, which prints output
//you can use object buffering if you need to manipulate or format the output
eo_locate_template( 'eo-loop-events.php', true, true );
exit;
} );
Stephen Harris
That works! Thank you very much! 🙂 Could you tell me as well which query variables I need for searching post titles and preview texts? I couldn’t find the right expression for that. Category and Tag search is working.
Something like this:
$args = array(
‘post_type’=>’event’,
‘showpastevents’=>true,
‘posts_per_page’=>-1,
‘event-category’=>’SomeCategory’,
‘post_title’=>’I am a post title.’, // this isn’t working
‘preview_text’=>’aword’, // this isn’t working
);
Regards, Tarek
-
This reply was modified 8 years, 2 months ago by Tarek Schneider.
Tarek Schneider
Hi Tarek,
Not sure what you mean by ‘preview_text’ (the excerpt?), but the ‘s’ parameter searches title and content.
Stephen Harris
Yes, i mean the excerpt! I tried the s parameter, but unfortunately all events are shown although there is no word ‘test’ in the title/text.
$args = array(
'post_type'=>'event',
'showpastevents'=>true,
'posts_per_page'=>-1,
'event-category'=>'sport',
's'=>'test',
);
query_posts( $args );
eo_locate_template( 'eo-loop-events.php', true, true ); ?>
-
This reply was modified 8 years, 2 months ago by Tarek Schneider.
-
This reply was modified 8 years, 2 months ago by Tarek Schneider.
-
This reply was modified 8 years, 2 months ago by Tarek Schneider.
-
This reply was modified 8 years, 2 months ago by Tarek Schneider.
Tarek Schneider
Hi Tarek,
This works for me. Have you tried deactivating other themes / plug-ins to see if there’s a conflict?
Stephen Harris
Yes, I cleaned up everything and now it’s working! Thank you for your help!
Tarek
Tarek Schneider