Link Posts Search – Left to Right only?
This topic contains 10 replies, has 4 voices, and was last updated by identity 5 years, 1 month ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: link events, link posts, linked posts, search, snippet
-
AuthorPosts
-
October 31, 2019 at 4:14 pm #515517
Okay, not sure if this is intentional or a bug…
It appears that when you use the link post feature to connect posts/events, that the search function to find related events is an exact match from left to right of the other posts title.
This seems like it could be very problematic and frustrating for users, especially with other posts that might start out with words like The, A, An, or even year placed at the start vs the end.
Example:
Event: The Great Food Fest
Won’t show up if someone doesn’t start the search with “The”Event: 2019 Chicago Beer Tasting
Won’t show up if someone searches for “Chicago 2019 Beer Tasting” or “Chicago Beer Tasting 2019.”I would rather they have to enter more than just two characters, but that the search would pull them up if they include something more specific from within the title:
Great Food, Chicago Beer Tasting, etc.
Bug? Intentional?
Cheers
November 1, 2019 at 5:04 am #515543Hi there,
Thanks for your post. Could you please share your Website URL here so that we could test on it?
November 1, 2019 at 3:35 pm #515586This reply has been marked as private.November 1, 2019 at 5:32 pm #515600You can adjust how many characters the user must enter in the search settings.
Which CPT are you searching? Events, and you are talking about the autocomplete function, for event titles?
November 1, 2019 at 9:18 pm #515616What I’m referencing is the Linked Posts functionality, that enables a user to link their post to another post.
For example, a bar owner has a listing and then wants to “link” their listing to an event listing. So on the backend where they enter the title of the event, it appears that the search function to find that other CPT must start out with the same letters of the title of that event (or other CPT).
So as referenced above, if they type “Great” but the event is titled “The Great Food Fest” it won’t return that event for them to connect to it.
Again, what I’m referencing is the backend search/link function, not the frontend search.
Cheers
November 2, 2019 at 4:53 am #515653Do you mean the Linked Posts Custom Field? Searching for the listing inside the field itself?
November 2, 2019 at 1:35 pm #515686Here are some screengrabs.
What I’m talking about is if someone creates a new listing or goes into their existing listing and want to link their listing to other listings, it appears that they must type the title of the listing they are wanting to link to in letter order from left to right, not a part of the title.
See screengrabs.
Cheers
November 3, 2019 at 4:38 pm #515759Thanks for clarifying.
That is in fact a very simple select2 autocomplete that works exactly as you say, left to right.
I will make a note about your request to improve that in future versions.
I’ll ask the developers to take a look, too.
November 3, 2019 at 8:53 pm #515784Alex, thanks.
Please do. This might “mean” the same thing, but just to make sure, this issue is not just on the “autocomplete” aspect…in this example, if you type in “roots picnic” and hit enter, not relying specifically on autocomplete, it still comes up with “no matches found.”
Either way, hope to see this improved for better user experience.
Thanks.
Cheers
November 11, 2019 at 11:13 am #516591Hello identity,
The post which being searched to link another post is already know to user, so we used matching exact results(Ex: The Great%) from right side. Add following PHP snippet to allow searching match from left and right side.
/** * Allow wildcard matching search link posts. */ function gd_snippet_191111_cp_search_posts_query_where( $where, $keyword, $post_type, $custom_field ) { global $wpdb; if ( $keyword != '' ) { $search = $wpdb->prepare( "p.post_title LIKE %s", array( $keyword . '%%' ) ); $replace = $wpdb->prepare( "p.post_title LIKE %s", array( '%' . $wpdb->esc_like( $keyword ) . '%' ) ); $where = str_replace( $search, $replace, $where ); } return $where; } add_filter( 'geodir_cp_search_posts_query_where', 'gd_snippet_191111_cp_search_posts_query_where', 20, 4 );
Kiran
November 11, 2019 at 5:24 pm #516653Excellent! I think it would be useful in the core code, but appreciate the work around at least.
cheers
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket