Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Franky

    (@liedekef)

    The next version will have a function call eme_wordpress_search(), containing this code:

    $table = $wpdb->prefix.EVENTS_TBNAME;
    $query = "SELECT * FROM $table WHERE (event_name LIKE '%%".$s."%%') OR
    (event_notes LIKE '%%".$s."%%') ORDER BY event_start_date";
    $sql=$wpdb->prepare($query,$_REQUEST['s'],$_REQUEST['s']);
    return $wpdb->get_results ( $sql, ARRAY_A );

    So then you can call at the beginning of search.php this:

    $events = eme_wordpress_search();

    And further down in search.php, change:

    <?php if ( have_posts() ) : ?>

    by

    <?php if ( have_posts() || !empty($events) ) : ?>

    And then, just above the call for <?php while ( have_posts() ) : the_post(); ?> (or wherever you want it), add something like this:

    <?php foreach ($events as $event) {
       print "<h2><a href='".eme_event_url($event)."'>".$event['event_name']."</a> ".$event['event_start_date']."</h2>";
       print substr($event['event_notes'],0,250)."[...]";
       print "<div style='clear:both;'></div>";
    } ?>

    Thread Starter asplash

    (@asplash)

    Thank you for this, great to hear it will be included in the next version.

    Many thanks, Jane

    Plugin Author Franky

    (@liedekef)

    Only the function ??
    The rest you’ll still need to change in your search.php, as indicated above.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Events in wordpress search’ is closed to new replies.