Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › URL’s not working correctly with Divi FAQ
- This topic has 11 replies, 2 voices, and was last updated 8 months, 2 weeks ago by
Shelly Rogers.
-
AuthorPosts
-
September 13, 2025 at 5:31 pm #55420
Shelly Rogers
ParticipantI have been using Ajax Search Pro for years and love it. But when I created a NEW instance dedicated for a new FAQ section, the url’s don’t work and all links get forwarded to the home page.
I am using a separate ajax search instance on the page that is dedicated for health insurance FAQ’s, searching only in this category and this page. This DOES NOT affect the main search bars, just the new one I created – [ajax_search_pro_HEALTH_FAQ] – [wd_asp id=6].
I am using the divi theme, with Divi FAQ Plugin With Structured Data from ET Premium. This FAQ creates unique url’s for each FAQ. When i click on the url, it takes the user to the FAQ page and scrolls down and opens the particular FAQ. Here is an example of a FAQ url that works correctly: https://www.nevadainsuranceenrollment.com/questions-faq/health-insurance-faq/#faq-item-what-is-a-health-insurance-subsidy.
The issue is, with ajax search pro, when clicking on any of the FAQ results from within a search, it uses this url: https://www.nevadainsuranceenrollment.com/?wpt-faq=what-is-a-health-insurance-subsidy.
The url from the ajax search is missing the category and post name “questions-faq/health-insurance-faq/”.
This happens to be oddly similar to the setting I use for my custom permalinks, which I add this to all urls: Custom Structure – https://www.nevadainsuranceenrollment.com/%category%/%postname%/.
Is there a way to add the category and post name to the ajax search results?
September 15, 2025 at 6:44 am #55421Ernest Marcinko
KeymasterHi,
Thank you very much for all the details and your kind words!
The search requests the URL for each element via the standard get_permalink function, which should always return the appropriate permalink registered to the element.
I’m guessing that the structured data plugin is likely registering these URLs somewhere, but it may not be directly to that hook so it doesn’t propagate.There is very likely a way to somehow get that URL programmatically via a function. I have looked up the plugin documentation but I couldn’t find any API or function reference to start with.
Can you please ask them via their support how to get the permalink programmatically via the FAQ ID? With that information I can construct a small custom coded snippet to replace the URLs with the ones generated by the plugin.
September 18, 2025 at 4:13 pm #55505Shelly Rogers
ParticipantThanks for looking into this.
This was the response from the developer.
—
Hi Shelly,The Divi FAQ plugin does not output any permalink.
We have a faq listing divi module which outputs the faq questions and answers on an accordian.
FAQ is a custom post type and rest all functionality is standard WordPress.
Hope it helps
Regards,
—September 19, 2025 at 7:55 am #55507Ernest Marcinko
KeymasterOh, that is a big shame. That basically means these URLs does not exist(?) and can’t be requested, probably generated on the frontend.
Still, there might be a hope to brute force it via converting the title to a hash, but I’m not sure:
add_filter( 'asp_results', function ( $results, $id, $is_ajax, $args ) { if ( $id != 6 ) { return $results; } $to_hash = function ( $str ) { $str = preg_replace('/\s+/', '-', strtolower($str)); return preg_replace('/[^A-Za-z0-9\-]/', '', $str); }; // -- Do not change anything below -- foreach ( $results as $k => $r ) { $r->link = 'https://www.nevadainsuranceenrollment.com/questions-faq/health-insurance-faq/#' . $to_hash($r->title); } return $results; }, 10, 4 );Try adding this code via the Code Snippets plugin or 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.
September 20, 2025 at 2:27 pm #55511Shelly Rogers
ParticipantThank you for that code. We are going in the right direction, because it does grab the category and page title now, but the individual FAQ id is off.
This is the actual url of the FAQ:
https://www.nevadainsuranceenrollment.com/questions-faq/health-insurance-faq/#faq-item-what-is-a-health-insurance-subsidyThis is what ajax is pulling up:
https://www.nevadainsuranceenrollment.com/questions-faq/health-insurance-faq/#what-is-a-health-insurance-subsidySo close….
September 21, 2025 at 12:37 pm #55514Ernest Marcinko
KeymasterOh I see, so It needs to add the “faq-item-” as prefix. Try this:
add_filter( 'asp_results', function ( $results, $id, $is_ajax, $args ) { if ( $id != 6 ) { return $results; } $to_hash = function ( $str ) { $str = preg_replace('/\s+/', '-', strtolower($str)); return preg_replace('/[^A-Za-z0-9\-]/', '', $str); }; // -- Do not change anything below -- foreach ( $results as $k => $r ) { $r->link = 'https://www.nevadainsuranceenrollment.com/questions-faq/health-insurance-faq/#faq-item-' . $to_hash($r->title); } return $results; }, 10, 4 );September 21, 2025 at 3:09 pm #55515Shelly Rogers
ParticipantErnest,
That works perfectly. Thank you.
I’ve used your product for multiple sites for over 10 years and have never had a problem.
But when I did have an issue (with another product), you fixed it.Amazing product, amazing customer service.
Thank you again,
September 21, 2025 at 3:10 pm #55516Ernest Marcinko
KeymasterYou cannot access this content.
September 21, 2025 at 3:58 pm #55517Shelly Rogers
ParticipantI didn’t think about this, but what do I do when I add duplicate, then add this search bar to the “AUTO’ insurance FAQ page?
I noticed the ‘health-insurance-faq’… is that for all search bars?
I have one for the main site – searches everything.
Then I have one for the health insurance FAQ section, auto FAQ, Homeowners FAQ etc.September 21, 2025 at 3:59 pm #55518Shelly Rogers
Participant$r->link = ‘https://www.nevadainsuranceenrollment.com/questions-faq/health-insurance-faq/#faq-item-‘ . $to_hash($r->title);
September 21, 2025 at 4:20 pm #55519Shelly Rogers
ParticipantCan I change this to 8 (the auto id) = if ( $id != 6 ) {
and change this to auto-insurance-faq (the auto url) = $r->link = ‘https://www.nevadainsuranceenrollment.com/questions-faq/health-insurance-faq/#faq-item-‘ . $to_hash($r->title);September 21, 2025 at 4:30 pm #55520Shelly Rogers
ParticipantI tried it and it works.
Thanks again for all the help. -
AuthorPosts
- You must be logged in to reply to this topic.