0

画像ブログのデザインに取り組んでいますが、いくつかの問題が発生しています。ライトボックスのメディア アイテムの「キャプション」領域を取得できましたが、「代替」領域または「説明」領域を取得できません。何か案は?

<?php if($attachment->post_excerpt): ?>alt="<?php echo $attachment->post_excerpt; ?>"<?php endif; ?>

(これは、メディア アイテムのキャプション エリアから取得するために使用するものです)

<?php $image = wp_get_attachment_image_src($attachment->ID, 'full'); ?>
                    <li><a href="<?php echo $image[0]; ?>" rel="prettyPhoto[gallery]" class="hover-gradient" title="untitled"><p style="display:none;"><?php if($attachment->post_excerpt): ?><?php echo $attachment->post_excerpt; ?><?php endif; ?></p><img src="<?php echo $thumbnail[0]; ?>" alt="gallery-blog" /></a></li>
                    <?php endforeach; endif; ?>

(これはホームページのサムの拡張コードです)

私は基本的に alt="gallery-blog" エリアを置き換えるものを探しているので、メディアページからメディアアイテムの代替テキストが表示されます

4

2 に答える 2

5

以下のように、メディアのタイトル、キャプション、および説明を取得できます

$alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
$image_title = $attachment->post_title;
$caption = $attachment->post_excerpt;
$description = $image->post_content;
于 2013-08-13T17:19:52.160 に答える
2

この関数は、、、、、を含む画像に関するすべてのwp_get_attachment_image();情報をエコーアウトします。altsrcwidthheightclass

コーデックス

于 2013-08-13T17:28:41.627 に答える