Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Search result to PDF
- This topic has 9 replies, 2 voices, and was last updated 9 months, 2 weeks ago by
99projects.
-
AuthorPosts
-
August 15, 2025 at 1:24 pm #55215
99projects
ParticipantHi, I bought the Media Service Pro add on this week and am having trouble with the search result going to the (PDF) document right away. It first directs me to a page with a link to the PDF, even though I tried different settings under ‘Media Service File Access Method’. Even though I have the settings (as you pointed out in your email to me this afternoon) as “Link the results to: attachment file directly” right from the beginning.
You can experience the problem I’m having when you search for ‘waterbeheer’. You will see a results page with a postcard type of layout.
When clicking on the title ‘BetonInfra Factsheet Duurzaam Waterbeheer’ it takes you to this page https://betoninfra.wpcomstaging.com/bi-factsheet-duurzaam-waterbeheer/ where there is a link to the PDF. Clicking the link finally show the PDf in the browser. But I would like the link on the search results page to go directly to the PDf in the browser. Hope you can tell me what’s wrong?Now I must say this is an Avada themed website by clients’ request (and I hate it) so maybe there’s an issue with that? To make matters worse it’s also hosted on WordPress.com. Sorry!
August 15, 2025 at 2:09 pm #55216Ernest Marcinko
KeymasterHi,
The results page can be tricky, it often times gets the URLs on it’s own from the stored permalinks, and in case of PDFs it’s usually the attachment page and not the direct file.
Since you are using Avada with fusion builder, there is a nice trick to make it still work. I have used the log-in and SFTP details and did the following:
1. On the editor, I have changed the result element link to an “Action” named
asp_change_res_page_url: https://i.imgur.com/jtVwSpz.png
2. Then to the child theme functions.php I have added this code to generate the PDF urls using that action:add_action('asp_change_res_page_url', function($url) { global $post; if ( isset($post->post_type) && $post->post_type === "attachment" ) { echo $post->guid; } else { echo $url; } }, 10, 1);Now, the code will trigger and for attachments it will return the file pointer, and for other result types the original URL.
August 16, 2025 at 10:03 am #5521899projects
ParticipantThank you so much, Ernest! This is wonderful and also your reply was fast!
August 18, 2025 at 6:31 am #55221Ernest Marcinko
KeymasterYou cannot access this content.
August 21, 2025 at 11:44 am #5525899projects
ParticipantYou cannot access this content.
August 21, 2025 at 2:42 pm #55277Ernest Marcinko
KeymasterThe issue was that the action was removed from the search result title and was replaced with the default permalink. I have changed it back to the action. Now it’s okay.
August 21, 2025 at 6:53 pm #5528399projects
ParticipantYou cannot access this content.
August 21, 2025 at 6:54 pm #5528499projects
ParticipantScreenshot of search results
August 21, 2025 at 6:55 pm #5528699projects
ParticipantScreenshot of page when clicking on the result
August 21, 2025 at 7:06 pm #5528899projects
ParticipantErnest, never mind… I see that it’s working correctly lining to the media files… but that I presumed that the results showed the pdf’s but those were posts that were created (I’m not sure how but maybe with an import I did earlier this month).
-
AuthorPosts
- You must be logged in to reply to this topic.