Created
February 20, 2020 14:01
-
-
Save MjHead/525db5dd35d3076a74c79cae6ff89086 to your computer and use it in GitHub Desktop.
Get attachment link by attachment ID callback for JetEngine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'jet-engine/listings/allowed-callbacks', 'jet_add_attachment_link_callback', 10, 2 ); | |
| function jet_add_attachment_link_callback( $callbacks ) { | |
| $callbacks['jet_get_attachment_file_link'] = 'Get attachment file link by ID'; | |
| return $callbacks; | |
| } | |
| function jet_get_attachment_file_link( $attachment_id ) { | |
| $url = wp_get_attachment_url( $attachment_id ); | |
| $name = basename( $url ); | |
| return sprintf( '<a href="%1$s">%2$s</a>', $url, $name ); | |
| } |
Good morning, is this function able to fetch all the files of the post or just one?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would be great if the "Dynamic Link" widget would give us the possibility to fetch the URL of the media field. If we now choose the media field as source the ID is being outputted. By using the "Dynamic Link" widget even the added icon would be wrapped into the link which would be great!
https://prnt.sc/rbxlng