Yoast\WP\SEO\Helpers
Image_Helper::get_caption()
Retrieves the caption for an attachment.
Метод класса: Image_Helper{}
Хуков нет.
Возвращает
Строку
. The caption when found, empty string when no caption is found.
Использование
$Image_Helper = new Image_Helper(); $Image_Helper->get_caption( $attachment_id );
- $attachment_id(int) (обязательный)
- Attachment ID.
Код Image_Helper::get_caption() Image Helper::get caption Yoast 22.4
public function get_caption( $attachment_id ) { $caption = \wp_get_attachment_caption( $attachment_id ); if ( ! empty( $caption ) ) { return $caption; } $caption = \get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ); if ( ! empty( $caption ) ) { return $caption; } return ''; }