Yoast\WP\SEO\Context
Meta_Tags_Context::get_singular_post_image()
Get the ID for a post's featured image.
Метод класса: Meta_Tags_Context{}
Хуков нет.
Возвращает
int|null
.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_singular_post_image( $id );
- $id(int) (обязательный)
- Post ID.
Код Meta_Tags_Context::get_singular_post_image() Meta Tags Context::get singular post image Yoast 24.6
private function get_singular_post_image( $id ) { if ( \has_post_thumbnail( $id ) ) { $thumbnail_id = \get_post_thumbnail_id( $id ); // Prevent returning something else than an int or null. if ( \is_int( $thumbnail_id ) && $thumbnail_id > 0 ) { return $thumbnail_id; } } if ( \is_singular( 'attachment' ) ) { return \get_query_var( 'attachment_id' ); } return null; }