Link Posts Search – Left to Right only?

This topic contains 10 replies, has 4 voices, and was last updated by  identity 5 years ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #515517

    identity
    Lifetime Member
    Post count: 445

    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

    #515543

    Kor
    Moderator
    Post count: 16516

    Hi there,

    Thanks for your post. Could you please share your Website URL here so that we could test on it?

    #515586

    identity
    Lifetime Member
    Post count: 445
    This reply has been marked as private.
    #515600

    Alex Rollin
    Moderator
    Post count: 27815

    You 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?

    #515616

    identity
    Lifetime Member
    Post count: 445

    What 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

    #515653

    Alex Rollin
    Moderator
    Post count: 27815

    Do you mean the Linked Posts Custom Field? Searching for the listing inside the field itself?

    #515686

    identity
    Lifetime Member
    Post count: 445

    Here 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

    #515759

    Alex Rollin
    Moderator
    Post count: 27815

    Thanks 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.

    #515784

    identity
    Lifetime Member
    Post count: 445

    Alex, 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

    #516591

    Kiran
    Moderator
    Post count: 7069

    Hello 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

    #516653

    identity
    Lifetime Member
    Post count: 445

    Excellent! I think it would be useful in the core code, but appreciate the work around at least.

    cheers

Viewing 11 posts - 1 through 11 (of 11 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount