Hi all,
Hoping someone with more PHP knowledge can help me echo an image description:
Using images in a query loop, I am using a text element with dynamic data ‘output PHP function’.
The function is a WP function of $image_description
I have tried many different ways but cannot seem to get it to output, variations I have tried include:
{echo:$image_description}
{echo:image_description}
{echo:$image_description (‘’)}
{echo:get_field($image_description)}
{echo:get_image_id($image_description)}
{echo:returnValues($image_description)}
And many other combinations too!
Anyone know where I have messed up? haha
Many thanks
Mick
1 Like
rjaureg
December 7, 2022, 10:43am
2
The WordPress function is wp_get_attachement_caption
You can try * {echo:wp_get_attachement_caption} maybe you don´t need to pass post ID if you are inside the post itself.
Hope this can help you
Michael
December 7, 2022, 12:02pm
3
Hi @rjaureg
Many thanks for the reply, but no luck, unfortunately. Again I am not overly sure if that function is for the caption and not the description, but I did try a couple of different variations of it just incase:
{echo:wp_get_attachment_caption}
{echo:wp_get_attachment_caption($image_description)}
{echo:wp_get_attachement_caption(image_description)}
But still no joy!
Wordpress has this function wp_get_attachment_image( $id ) but it returns an array so cannot be used as you want to get the description.
You should use this code for that
$attachment_meta = wp_get_attachment_images['attachment_id']);
echo $attachment_meta['description'];
On the other side, $image_description is a variable that you are using on your site?
The way Bricks buider use output function is like this:
Use dynamic data to render all sorts of data from your WordPress database with Bricks. For example: Featured image, post title, post date, author name, categories, tags, site title, all of your custom fields, etc. You’ll most likely use dynamic data...
It accepts arguments, with or without single quotes, like so:
{echo:get_the_date(‘Y-m-d’, 55)}`
This echoes the date of the post 55 formatted to `Y-m-d’
But I don´t know how to pass a variable which whould be a very useful thing,
Maybe someone can help with this, sorry …
4 Likes