Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arunbasillal/46258942dd56df0a1d9e9698b8c67bfc to your computer and use it in GitHub Desktop.
Save arunbasillal/46258942dd56df0a1d9e9698b8c67bfc to your computer and use it in GitHub Desktop.
IAP: Custom tag %pr_post_author% for Image Attributes Pro
/**
* Custom tag %pr_post_author% for Image Attributes Pro
*
* @param $image_id (integer) The ID of the image that is being updated.
* @param $parent_post_id (integer) Post to which the image is attached (uploaded) to.
* @param $args (array) An array containing additional arguments.
*
* @return (string) Author of the post / page / product if available. Empty string otherwise.
*
* @refer https://imageattributespro.com/codex/iaffpro_get_custom_attribute_tag_tagname/
*/
function iaffpro_get_custom_attribute_tag_pr_post_author( $image_id, $parent_post_id, $args = array() ) {
if ( $parent_post_id == 0 ) {
return '';
}
$author_id = get_post_field( 'post_author', $parent_post_id );
$display_name = get_the_author_meta( 'display_name' , $author_id );
return $display_name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment