Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Attachment – Links Results to Attachment Page issue
This topic contains 9 replies, has 2 voices, and was last updated by Ernest Marcinko 4 years, 9 months ago.
- AuthorPosts
- February 25, 2019 at 1:13 am #21239
Hi!,
Purchased Ajax Search Pro yesterday and I have been working through its features – I am impressed and overall happy with it thus far! I have a photography site and when a user searches and finds an Attachment, I want them to be able to click the results thumbnail and ideally view the image in a lightbox. I have read through the forums and I see that may be an issue. So the next approach that I am trying to have work is to at least display the selected result image on images “attachment page”. Unfortunately when I select this option in the Attachments menu “Link results to: attachment page” the site sill always opens up the direct file url. For example it opens: “https://photography.toddplunkett.com/wp-content/uploads/2019/02/DSC09388.jpg” instead of the attachment page for that image. Am I missing a configuration setting somewhere that is causing this to happen?
On the lightbox topic, I use the justified image grid plugin and it has significant flexibility in how it can receive post and image IDs and custom urls to open an image in one of its lightbox options. I am betting there is a way to make this happen. I wonder if you have explored it at all. It works very well – if I could figure out how to pass a Post ID from a search result, it can open it in a lightbox.
Thank You for your help!
February 25, 2019 at 2:41 pm #21250Hi,
Thank you very much for your kind words!
I just tested that feature, but it seems to be working okay on my end. The ‘attachment page’ is basically the attachment parent, that is the relation to the page where the attachment was uploaded to. I’m guessing that maybe an internal WordPress option also affects that, I am not sure.
Anyways, I think I might know how to bypass that. If you want to test this fix, then please follow these steps:
1. Make sure to have a full site back-up just in case 🙂
2. Open up the wp-content/plugins/ajax-search-pro/includes/classes/search/class-asp-search-attachments.php file on your server via FTP
3. Replace it’s contents with this
4. Save the file, and it’s done
Hopefully, that should force the correct attachment page URL.As for the post ID, it is possible to get it when clicking on the result, via a custom script. I have made a script sample for you, that may help you with that:
add_action('wp_footer', 'asp_add_custom_js', 99); function asp_add_custom_js() { ?> <script> jQuery(function($) { $('.asp_r').on('click', '.item', function(e) { // Is this an attachment result? if ( $(this).hasClass('asp_r_attachment') ) { // Prevent result redirection e.preventDefault(); e.stopImmediatePropagation(); // use the post_id and url variables as you like var post_id = $(this).attr('class').match(/asp_r_attachment_(.*?) /)[1]; var url = $(this).find('a.asp_res_url').attr('href'); } }); }); </script> <?php }
I hope this helps!
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 25, 2019 at 3:02 pm #21257Ernest – Thank you for your very prompt reply – fantastic customer service. I will test this out today and report back my findings.
February 25, 2019 at 3:19 pm #21262You cannot access this content.February 25, 2019 at 3:24 pm #21264Hi,
The dev tools does not help in this case, as the correction is a server side script. If you want, you can add temporary FTP details, and I will try debugging the code directly. That internal function should return the attachment page url, unless there is a 3rd party filter applied to it. I might be able to tell, via debugging that code section.
The second code should go to the functions.php file in your theme/child theme directory. Sorry about that, I forgot to mention. It does nothing though, it’s just a sample on how to get the ID and the links. The post_id and the url variables in the script contain the attachment ID and the image URL. So if the lightbox script has an API, you can use that there, with those variables.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 25, 2019 at 4:54 pm #21265You cannot access this content.February 26, 2019 at 3:55 am #21273You cannot access this content.February 26, 2019 at 10:56 am #21282You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 26, 2019 at 2:16 pm #21286For anyone who runs into this issue, I wanted to let you know the problem seems to have been caused by the Yoast SEO plugin conflicting. I disabled it and all works fine. (For now I have implemented the The SEO Framework plugin without conflict)
Thanks Again to Ernest for his assistance and very prompt support response!
February 26, 2019 at 3:13 pm #21291You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.