Я хотел бы спросить, как получить конкретный атрибут title wordpress image со словарного носителя?получить конкретный атрибут title wordpress image
Данные, вводимые при загрузке изображений, заголовков, субтитров, описания.
Я хотел бы спросить, как получить конкретный атрибут title wordpress image со словарного носителя?получить конкретный атрибут title wordpress image
Данные, вводимые при загрузке изображений, заголовков, субтитров, описания.
Вы можете найти определенный атрибут прикрепления изображения Wordpress.
<?php
$attachment_id = 8; // attachment ID
$image_attributes = wp_get_attachment_image_src($attachment_id); // returns an array
if($image_attributes) {
?>
<img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>">
<?php } ?>
An array containing:
[0] => url
[1] => width
[2] => height
[3] => boolean: true if $url is a resized image, false if it is the original or if no image is available.
Это должно вам помочь.
$title = get_post(get_post_thumbnail_id())->post_title; // Title
$caption = get_post(get_post_thumbnail_id())->post_excerpt; // Caption
$description = get_post(get_post_thumbnail_id())->post_content; // Description
Hai Ferrrmolina Я пробовал использовать заголовок $, но заголовок сообщения появляется, а не название конкретного изображения из медиа-библиотеки. – njhelloworld
Я увидел код из http://wordpress.stackexchange.com/questions/185396/getting-the-image-title-alt-attribute-from-the-gallery-shortcode , но он выводит пустой. – njhelloworld
Посмотрите, что: http://www.bobz.co/how-to-get-attachment-image-caption-alt-or-description/ – Ferrrmolina