如何获取每个图库图像'Alt属性,然后在每个属性后面添加它们作为标题


How to get each gallery images' alt attribute, and then add them as a header after each of them

我想给我的wordpress图库图像一些漂亮的布局,但我甚至不知道如何开始。你能帮我一下吗?

这就是我所得到的,但我认为这在很多层面上都是错误的。我想有一个figcaption下的每个图像与他们的标题。我该如何处理这个问题?

    jQuery(document).ready(function($) {
var alt = $(".attachment-thumbnail").attr("alt");
$('.attachment-thumbnail').after('<figcaption><h5 class="centered">', alt , ' </h5></figcaption>');
})

像这样连接:

$('.attachment-thumbnail').after('<figcaption><h5 class="centered">' + alt + '</h5></figcaption>')