Last active
April 9, 2023 10:23
-
-
Save arunbasillal/6ee391d5e6e8ec0ee755d0bf2c8a2a12 to your computer and use it in GitHub Desktop.
Custom tag %pr_yoastmetadesc% for Image Attributes Pro that returns Yoast Meta Description.
This file contains 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
/** | |
* Custom tag %pr_yoastmetadesc% for Image Attributes Pro that returns Yoast Meta Description. | |
* | |
* @link https://yoast.com/developer-blog/yoast-seo-14-0-using-yoast-seo-surfaces/ | |
* | |
* @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) Yoast Meta Description. | |
* | |
* @refer https://imageattributespro.com/codex/iaffpro_get_custom_attribute_tag_tagname/ | |
*/ | |
function iaffpro_get_custom_attribute_tag_pr_yoastmetadesc( $image_id, $parent_post_id, $args = array() ) { | |
if ( $parent_post_id == 0 ) { | |
return; | |
} | |
if ( ! function_exists( 'YoastSEO' ) ) { | |
return ''; | |
} | |
return YoastSEO()->meta->for_post( $parent_post_id )->meta_description; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment