Функция get_post_thumbnail_id() в WordPress с примерами