Using eo_events to display specific events by search

WordPress Event Management, Calendars & Registration Forums General Question Using eo_events to display specific events by search

This topic contains 3 replies, has 2 voices, and was last updated by  Stephen Harris 10 years, 1 month ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #14469

    Hi

    I have many events with the same title eg Project Management.

    I wish to use the eo-event to display only the event with title project management. How do I do this?

    Hayley Gillman
    #14501

    The API only supports search by title, (eo_get_events() extends WordPress’ get_posts()/WP_Query API) i.e.

    $events = eo_get_events( array( 
        's' => 'Project Management'
    ) );
    

    will get events with a title like “Project Managment” (so it would return events with titles such as “This is not project management” and “project managements”. This might be good enough, but if not you would need to edit the SQL statement (using something like the posts_where filter – http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where).

    The best way to do this would be to use a custom query variable:

    $events = eo_get_events( array( 
        'events_with_title' => 'Project Management'
    ) );
    

    Then on the posts_where filter, check if $query->get( 'events_with_title' ) returns something other than false. And if so insert the SQL segment:

    "AND post_title='XXXX' "
    

    where XXXX is replaced by the properly sanitised value from $query->get( 'events_with_title' ). (See $wpdb::prepare()http://codex.wordpress.org/Class_Reference/wpdb#Protect_Queries_Against_SQL_Injection_Attacks )

    Stephen Harris
    #14630

    Hi Thanks for feedback

    It is first option. ANy titile with proejct management.
    $events = eo_get_events( array(
    ‘s’ => ‘Project Management’
    ) );

    Please can you give me code I would like to show event, start date, end date.

    When I put the code in wordpress it just appears as text and doesn’t do anything- I am working in text editor – please help

    Hayley Gillman
    #14644

    Hi Hayley, they’re are examples here on displaying the results of eo_get_events(): http://codex.wp-event-organiser.com/function-eo_get_events.html (see also this section in the documentation: http://docs.wp-event-organiser.com/querying-events/overview/).

    You’ll need to wrap php code in <?php ... ?> tags in order for it to be excuted instead of displayed. If you’re not sure, I’d recommend hiring a developer.

    Or you can use the event list shortcode:

     [eo_events s="Project Management"]
    
    Stephen Harris
Viewing 4 posts - 1 through 4 (of 4 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.