Can I get the ID of an inserted / linked image?
-
02-11-2019 - |
Вопрос
I am using this code to get the url of first inserted image in a post. Is there any way I can get the ID of that image.
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_image = $matches [1] [0];
Нет правильного решения
Не связан с wordpress.stackexchange