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

Reply To: Search result to PDF

#55216
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

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.