Hello,
We have a section (custom post type) of our client's website for uploading digital documents (PDFs). I'd like for the permalink to be directed to the PDF URL that has been uploaded
If they do not upload to the site and only provide a URL for the document, then I'd like the permalink to be directed to the URL.
See screenshot for more notes.
Thank you!
A File Field of Toolset will, if output on the front end, produce a Link to the PDF that can be clicked to reach the PDF.
However Custom Fields are not redirecting, these cannot be used for this.
Redirects are something managed on HTACCESS Level, where Toolset does not help you as it is a plugin for the design of the website.
You could use some custom code that checks the content of a post when visited, and if it contains an URL to a PDF, then redirect to that, but you'd never be able to actually see the very post, as it would always redirect to the PDF.
Toolset Support cannot help with such code, as it is out of Toolset's scope, but we can recommend contractors listed here https://toolset.com/contractors/ if you need help with the custom code.
Similarly, if there is no PDF but an URL, while you can store, and display that with Toolset, Toolset doesn't provide any means of redirecting to specific URLs as you require.
You can use the Field as the redirect, in your custom code, this is possible because the Toolset Field is just like any other WordPress Custom Field and you can hence either get it with get_post_meta() or as said, with some code that scans the content for such eventual content.
get_post_meta is elaborated here:
https://developer.wordpress.org/reference/functions/get_post_meta/