Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › CPT Title search returns no results
- This topic has 9 replies, 2 voices, and was last updated 4 years, 1 month ago by
Ernest Marcinko.
-
AuthorPosts
-
March 31, 2022 at 12:04 am #37343
Bill Kellaway
ParticipantI’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/March 31, 2022 at 1:15 pm #37348Ernest Marcinko
KeymasterHi!
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!
April 12, 2022 at 10:30 pm #37510Bill Kellaway
ParticipantErnest,
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
April 13, 2022 at 6:13 pm #37523Ernest Marcinko
KeymasterYou 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.
April 13, 2022 at 6:24 pm #37524Bill Kellaway
ParticipantThanks Ernest for that however I am afraid it breaks the search results ..
see https://www.loom.com/share/a2dae9d114f944a5920b68b22e28da30
April 13, 2022 at 6:40 pm #37525Ernest Marcinko
KeymasterI 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; }April 13, 2022 at 7:42 pm #37526Bill Kellaway
ParticipantMaking progress – that worked – however it also affected the other search which does not use the custom search results ..
April 14, 2022 at 2:27 pm #37532Ernest Marcinko
KeymasterOkay, 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.
April 15, 2022 at 8:40 pm #37545Bill Kellaway
ParticipantThanks Ernest !
You can close this – see my attached review.
April 19, 2022 at 11:58 am #37556Ernest Marcinko
KeymasterYou cannot access this content.
-
AuthorPosts
- The topic ‘CPT Title search returns no results’ is closed to new replies.