This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

CPT Title search returns no results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support CPT Title search returns no results

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #37343
    Bill KellawayBill Kellaway
    Participant

    I’ve duplicated a search form that works and removed one parameter. The new form is not working.

    Please see this video: https://www.loom.com/share/ad2dbfdf53d046ce9164a78e1b44d5c6

    You will need to log in with two browsers to test. One for the admin then another to log in as a user.
    Go to users – select kwetzel and login as user. The search form is on this page:
    https://bridlewoodstag.wpengine.com/agent-portal/management/agency-reports/

    #37348
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    Thanks for the details, I logged in, and very likely found the issue. There is a custom field filter enabled on the second search bar as well, which only allows “approved” agents to show up: https://i.imgur.com/19eVXE0.png
    I suspect, that if you remove that filter, it will start working as expected.

    I hope this helps!

    #37510
    Bill KellawayBill Kellaway
    Participant

    Ernest,

    Thanks so much that was an easy one! Sometimes you need a second pair of eyes. Thanks.

    So I have another issue generating custom search results. Please see this video.

    https://www.loom.com/share/697931eda44d4390945ed36389436d5b

    Thanks,

    Bill

    #37523
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You are welcome!

    The problem with that setting is, that it applies only for user type results, and you are returning custom post types, so it does not apply there.

    The only way to do that is via a custom code, although it should not be too difficult, something like this should do it:

    add_filter('asp_results', 'asp_results_custom_url', 10, 1);
    function custom_asp_redirect_url($results) {
    	foreach ( $results as $k => &$r ) {
    		$r->link = get_site_url() . '/agent-portal/management/agent-profile-update/?agent_ID=' . $r->id;
    	}
    	
    	return $results;
    }

    Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    #37524
    Bill KellawayBill Kellaway
    Participant

    Thanks Ernest for that however I am afraid it breaks the search results ..

    see https://www.loom.com/share/a2dae9d114f944a5920b68b22e28da30

    #37525
    Ernest MarcinkoErnest Marcinko
    Keymaster

    I may have made a typo there, try:

    add_filter('asp_results', 'custom_asp_redirect_url', 10, 1);
    function custom_asp_redirect_url($results) {
    	foreach ( $results as $k => &$r ) {
    		$r->link = get_site_url() . '/agent-portal/management/agent-profile-update/?agent_ID=' . $r->id;
    	}
    	
    	return $results;
    }
    #37526
    Bill KellawayBill Kellaway
    Participant

    Making progress – that worked – however it also affected the other search which does not use the custom search results ..

    https://www.loom.com/share/bf691b403f374a2db715741f226a56e3

    #37532
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Okay, that should be still possible:

    add_filter('asp_results', 'custom_asp_redirect_url', 10, 2);
    function custom_asp_redirect_url($results, $search_id) {
    	$apply_on_id = 1;
    	
    	if ( $apply_on_id == $search_id ) {
    		foreach ( $results as $k => &$r ) {
    			$r->link = get_site_url() . '/agent-portal/management/agent-profile-update/?agent_ID=' . $r->id;
    		}
    	}
    	
    	return $results;
    }

    Change the $apply_on_id variable to the search ID you want the code to apply on, and it should be fine.

    #37545
    Bill KellawayBill Kellaway
    Participant

    Thanks Ernest !

    You can close this – see my attached review.

    #37556
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘CPT Title search returns no results’ is closed to new replies.