Events Made Easy › Forums › How do I … › How do I find events and locations in the editor's link menu?
- This topic has 10 replies, 2 voices, and was last updated 6 years, 5 months ago by Anonymous.
-
AuthorPosts
-
Sat 2 Jun 2018 at 19:16 #58111AnonymousInactive
The WP editor offers the link menu to easily add links to the texts and has the search function to link to existing posts and pages. Is there a way to insert EME events and locations in this search?
Sat 2 Jun 2018 at 23:09 #58115FrankyKeymasterHooking into wp_link_query can work maybe … to test …
Wed 6 Jun 2018 at 20:21 #58119AnonymousInactiveWith this key word I found this https://gist.github.com/carasmo/133d33a98ee66171df9132ec0f2168c7
Also a nice thing to have. But with my leaking knowledge and understanding I am not sure if and how I should continue now. Would you give me a hint please how to go further?
Thu 7 Jun 2018 at 09:37 #58121FrankyKeymasterHooks in wordpress are explained by wordpress 🙂
But, read the eme FAQ on “How to add events to your wordpress search results?”, which is partly related (also a hook etc …). The only thing there is: I use a function called eme_wordpress_search_events(), and that function might need some tweaking for the url-search you want (if not the same POST param is used). Also, no time now, but I don’t know if there’s a eme_wordpress_search_locations() function too … and you need (as url) to use the functions eme_event_url($event) and eme_location_url($location) and use the returned url in your results to add to the array of urls.
I haven’t found the time to play around with this yet …Fri 8 Jun 2018 at 17:36 #58128AnonymousInactiveThanks for already have taken the time to present these bricks. Even if I am not able to deal with them just like that. I guess I will come back to this when I feel more capacity in my mind and am more eager to learn the necessary things. Or maybe someone else has the need and knowledge to realize it in the meantime 😉
Wed 13 Jun 2018 at 12:33 #58148FrankyKeymasterThis seems to do the trick (add to your theme’s function.php):
add_filter('wp_link_query', 'eme_add_events_link_search', 10, 2); add_filter('wp_link_query', 'eme_add_locations_link_search', 10, 3); function eme_add_events_link_search($results,$query) { if (!isset($query['s'])) return; if ( $query['offset'] > 0 ) : // Add only on the first result page return $results; endif; $events=eme_search_events($query['s']); foreach ($events as $event) { $results[]= array( 'ID' => $event['event_id'], 'title' => trim( esc_html( strip_tags($event['event_name']) ) ) , 'permalink' => eme_event_url($event), 'info' => 'Event', ); } return $results; } function eme_add_locations_link_search($results,$query) { if (!isset($query['s'])) return; if ( $query['offset'] > 0 ) : // Add only on the first result page return $results; endif; $locations=eme_search_locations($query['s']); foreach ($locations as $location) { $results[]= array( 'ID' => $location['location_id'], 'title' => trim( esc_html( strip_tags($location['location_name']) ) ) , 'permalink' => eme_location_url($location), 'info' => 'Location', ); } return $results; }
Wed 13 Jun 2018 at 20:27 #58149AnonymousInactiveAmazing! Thanks a lot for that working piece of extra code. It seems to do what I wanted. I am not sure yet if I welcome the fact that all entries of an recurring event are listed. Would it be easy to adjust the code for only showing single events?
By checking this function I discovered that the code I linked above (to find categories and tags) isn’t working properly. The results are repeated all over again and again. The most obvious thing to do is to contact the author, sure. But maybe you have taken a look at it or even used it to approach your solution and perhaps seen something that my cause this? I am aware that it is far out of your business, just wondering.
Fri 15 Jun 2018 at 11:25 #58152FrankyKeymasterThe next version of EME will have an option that allows to activate/deactivate the link search for events/locations. I also added the date for events, so you can better distinguish events in a recurrent series (I will not remove those from the search though since that would defeat the purpose of it all).
Mon 18 Jun 2018 at 09:22 #58156AnonymousInactiveVeeeery good. Thank you a lot.
Mon 18 Jun 2018 at 13:53 #58157FrankyKeymasterConcerning your question about the github code: it seems the second function (for linking terms) doesn’t contain the following 3 lines (like the first function):
if ( $query['offset'] > 0 ) : // Add only on the first result page return $results; endif;
I’m guessing that’s causing the results to be repeated …
Mon 18 Jun 2018 at 18:32 #58158AnonymousInactiveYou guessed right. Very kind of you to help me also with that.
-
AuthorPosts
- The forum ‘How do I …’ is closed to new topics and replies.