- April 11, 2018 at 6:20 am #17471
This question is actually for a new purchase and not the one I see listed above when I post the question. I provided the new website link in the private details. Purchase code can be shared if you need it.
We have a custom post type for our products. Three fields on this page that are relevant to this question are the (1) SKU and the (2) product name and (3) link to a warranty in the form of a PDF. To note – we are storing the ID Of the PDF attachment since the relationship of warranties to products is 1 to many.
What we want to do is allow a user to type in a SKU or product name into the search bar and then the results will show the product name and image – but instead of linking to the Product custom post or page itself, we want it to link directly to the PDF of the warranty.
I see where you can use a custom structure to link to user search – but not sure how to do the same with a regular search?
I can provide login information if needed.April 11, 2018 at 10:57 am #17476
This should be doable, but with a custom code only. I have constructed a custom filter function, that will execute during the search post-process, and get the ID from the custom field, then get the link to the attachment file based on that id. Just change the $custom_field variable value to the custom field that contains the attachment ID.
Add this custom code to the functions.php in your theme/child theme directory (copy from line 3 only!). Before editing, please make sure to have a full site back-up just in case!
I hope this helps.Best,
If you like my products, don't forget to rate them on codecanyon :)
You must be logged in to reply to this topic.