Skip to content

Instantly share code, notes, and snippets.

@arunbasillal
Last active April 24, 2023 07:17
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/5e5a287dea569304b87718b413c3985f to your computer and use it in GitHub Desktop.
Save arunbasillal/5e5a287dea569304b87718b413c3985f to your computer and use it in GitHub Desktop.
Custom tag %product_description% for Image Attributes Pro
/**
* Custom tag %product_description% for Image Attributes Pro
*
* @param $image_id The ID of the image that is being updated.
* @param $parent_post_id The post to which the image is attached (uploaded) to.
* @param $args (array) An array containing additional arguments.
*
* @return string WordPress post content. WooCommerce product long description is saved as post content.
*
* @refer https://imageattributespro.com/codex/iaffpro_get_custom_attribute_tag_tagname/
*/
function iaffpro_get_custom_attribute_tag_product_description( $image_id, $parent_post_id, $args = array() ) {
if ( $parent_post_id === 0 ) {
return '';
}
$post = get_post( $parent_post_id );
$content = substr( $post->post_content , 0, 20 ); // Change 20 to desired value to increase or decrease characters.
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment