I am a novice coder. I'm using Wordpress. I use this working snippet to display image captions below the image:
<script>
jQuery('.ce-image').find('img').after(function(){
return jQuery('<p class="image-caption">').text(jQuery (this).attr('caption')); }
);
I would like to also display the title and description fields from my images. But when I plug in title and description into (this.attr('FIELD HERE')) it's not working. I am stuck as to why. The title and description fields do have data in them, but it can't seem to grab it.
For example, this snippet of code doesn't return anything:
<script> jQuery('.ce-image').find('img').after(function() { return jQuery('<p class="image-caption">').text(jQuery (this).attr('title')); }); </script>
Is the syntax different for the title and description fields? Using the alt field is working for me, caption is working, but title and description fields are not. Is there another, similar approach I could be trying? Thanks in advance for any help.