I have a CPT Documents where a file can be uploaded (pdf, xslx, jpg, ...).
I would like to display the proper file extension icon in the View.
Can I get somehow get the file extension from an uploaded file so I can use it in a condition? Or can I only test against the whole file upload path?
Note:
Before using a custom shortcode inside a conditional, you need to register it. To do so, visit the Toolset -> Settings page and click the Front-end Content tab. There, simply add your shortcode "get_file_extension" (without quotes) to the Third-party shortcode arguments section.
For instance:
[wpv-conditional if="( '[get_file_extension url="[types field='file' output='raw'][/types]"]' eq 'pdf' )"]
PDF file icon display here
[/wpv-conditional]
I have
- pasted the snippet in the functions.php of the theme file.
- added the custom snippet via Toolset > Settings
But when I use [get_file_extension url="[types field='document-linked-files' output='raw'][/types]"]
It just displays: [get_file_extension url="hidden link"]
so the shortcode is not working.