Community Forums › Forums › Archived Forums › General Discussion › Adding EME events to search
Tagged: events made easy, php, search
- This topic has 4 replies, 2 voices, and was last updated 6 years, 8 months ago by Robert Falkowitz.
-
AuthorPosts
-
May 12, 2018 at 8:07 am #219799Robert FalkowitzParticipant
Am using the Infinity Pro theme and an event management plugin named "Events Made Easy" (EME). Since that plugin does not use the same table as posts to store the events, events do not appear in the standard search functionality.
However, the plugin gives the following advice on how to add its events to search:
So, create a child theme and edit search.php there.
At the beginning of search.php, add this line:$events = eme_wordpress_search_events();
In EME before version 1.7.11, this is called just eme_wordpress_search() and will be available as backwards compatibility function call.
Further down in search.php, change:<?php if ( have_posts() ) : ?>
to:
<?php if ( have_posts() || !empty($events) ) : ?>
And then, just above the call for (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>"; } ?>
This advice does not look remotely like what I can find in Genesis/Infinity Pro, so I wonder if someone has already done this in a Genesis theme and can indicate how to adapt the instructions accordingly.
Thanks!
May 12, 2018 at 11:11 am #219808Brad DaltonParticipantThis might help https://wpsites.net/web-design/custom-fields-on-search-results-page/
You'll need to integrate your code however its a step in the right direction.
May 13, 2018 at 2:53 am #219812Robert FalkowitzParticipantThanks for this, Brad. I don't think the logic of those solutions, based on checking custom fields with the post table, will apply to my case.
Still looking...May 13, 2018 at 5:26 am #219815Brad DaltonParticipantI meant creating a custom search.php file.
And then hooking in your code using the genesis_entry_content hook.
Remove the part for the custom fields and replace it with your code like this :
add_action( 'genesis_entry_content', 'search_page', 12 ); function search_page() { // Add your code here }
May 13, 2018 at 9:56 am #219824Robert FalkowitzParticipantThe problem is in getting the output concerning the matching events to appear only once, on the last page of the output, but before the bit at the bottom of the page that allows the visitor to select the page of output to which to jump.
For example, if there are 6 pages of output for a search and you are on the 6th page, here is what I would like to display:
<the last post/page should appear here>
<the list of matching events should appear here>
<and then finally, the page selector options, such as:>
« Previous Page Page 1 Page 2 Page 3 Page 4 … Page 6 Next Page »
With all the hooks I tried (genesis_entry_content, genesis_after_loop, genesis_before_loop), either the output for the matching events appears on every page, or after the page selector options.
Is there a hook that does what I want, or do I have to build the logic into the search.php that calculates how many pages of output there will be and then displays the event output only on the last page, using the genesis_entry_content hook?
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.