wordpress - ACF plugin finding ID for image for PHP to display in page -
i have wordpress site using acf plugin.
what i'm trying achieve this:
using plugin allow php in posts, trying code display image using shortcode given acf
what have far is
<?php echo wp_get_attachment_image( 'id' ) ?> displays image need <?php the_field('mobile_poster'); ?> displays id image
what hasn't worked has been using
<?php echo wp_get_attachment_image( '[acf field="mobile_poster"] ') ?>
any ideas on how achieve appreciated.
kind regards,
ben
you can try shortcode:
<?php echo do_shortcode( '[acf field="{$field_name}" post_id="{$post_id}"]' ) ?>
for display acf field value
if trying find image have id of custom field can write code
<?php $attachment_id = do_shortcode( '[acf field="{$field_name}"]' ) ; wp_get_attachment_image_src( $attachment_id ); ?>
Comments
Post a Comment