integrate events into wp-search
-
Hallo Franky,
I got problems to integrate the events into the regular wordpress text-search.
I′ve found this thread ( https://www.e-dynamics.be/wordpress/?topic=include-your-events-in-the-search-result ) and put the mentioned code into the search.php, but I m gettin the following error message, when using the searchfield:
Warning: mysql_real_escape_string(): No such file or directory in /homepages/3/d434234131/htdocs/pph-net/wp-content/themes/hueman/search.php on line 26
Warning: mysql_real_escape_string(): A link to the server could not be established in /homepages/3/d434234131/htdocs/pph-net/wp-content/themes/hueman/search.php on line 26
Underneath these error messages it shows all events starting with the first event inserted I guess.
What might be the reason? What am I doing wrong?
My search.phpis the following:
<?php get_header(); ?> <section class="content"> <?php get_template_part('inc/page-title'); ?> <div class="pad group"> <div class="notebox"> <?php _e('For the term','hueman'); ?> "<span><?php echo get_search_query(); ?></span>". <?php if ( !have_posts() ): ?> <?php _e('Please try another search:','hueman'); ?> <?php endif; ?> <div class="search-again"> <?php get_search_form(); ?> </div> </div> <?php $table = $wpdb->prefix."eme_events"; $s = mysql_real_escape_string($_REQUEST['s']); // The search key words $found_event = false; $query = "SELECT * FROM $table WHERE (event_name LIKE '%".$s."%') OR (event_notes LIKE '%".$s."%') ORDER BY event_start_date"; $events = $wpdb->get_results ( $query, ARRAY_A ); foreach ($events as $row) { print "<h2><a href='".get_bloginfo('url')."/events/?event_id=".$row['event_id']."'>".$row['event_name']."</a> ".$row['event_start_date']."</h2>"; print substr($row['event_notes'],0,250)."[...]"; print "<div style='clear:both;'></div>"; $found_event = true; } ?> <?php if ( have_posts() ) : ?> <?php if ( ot_get_option('blog-standard') == 'on' ): ?> <?php while ( have_posts() ): the_post(); ?> <?php get_template_part('content-standard'); ?> <?php endwhile; ?> <?php else: ?> <div class="post-list group"> <?php $i = 1; echo '<div class="post-row">'; while ( have_posts() ): the_post(); ?> <?php get_template_part('content'); ?> <?php if($i % 2 == 0) { echo '</div><div class="post-row">'; } $i++; endwhile; echo '</div>'; ?> </div><!--/.post-list--> <?php endif; ?> <?php get_template_part('inc/pagination'); ?> <?php endif; ?> </div><!--/.pad--> </section><!--/.content--> <?php get_sidebar(); ?> <?php get_footer(); ?>
- The topic ‘integrate events into wp-search’ is closed to new replies.