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 ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good morning, is this function able to fetch all the files of the post or just one?