Cornerstone - recent posts - ACF image

Hi there,

i´m using a custom post type with ACF and one of my ACF values is an image.

When using cornerstone to display the recent CPT it shows the featured image of the post by defaut.

How can i change it, i want it to show another image instead, one of the ACF fields.

thanks

Hi there @apxds,

The standard integration with ACF is relatively simple whereby Cornerstone will output the content but for more advanced parts of ACF, you’ll need custom code.

Because of how this works, you’ll need to use the ACF get_field custom code depending on the exact image you want, ACF cover this in their documentation here: https://www.advancedcustomfields.com/resources/image/

Any issues let us know.

Thanks!

Hey Jack,
Thanks for the answer but it´s not working with the image…

i did with a text field and it did work

i did try the Basic display (array) and others but no image appears.

<?php // ============================================================================= // VIEWS/RENEW/WP-SINGLE.PHP // ----------------------------------------------------------------------------- // Single post output for Renew. // ============================================================================= $fullwidth = get_post_meta( get_the_ID(), '_x_post_layout', true ); ?> <?php get_header(); ?>
<div class="<?php x_main_content_class(); ?>" role="main">

  <?php while ( have_posts() ) : the_post(); ?>
    <?php x_get_view( 'renew', 'content-depoimentos', get_post_format() ); ?>

    <div style="padding-right:20%;"><p><?php the_field('depoimento'); ?></p></div>


    <?php

$image = get_field(‘foto-depoimento-intercambio’);

if( !empty($image) ): ?>

<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?>
    <?php x_get_view( 'global', '_comments-template' ); ?>
  <?php endwhile; ?>

</div>

<?php if ( $fullwidth != 'on' ) : ?>
  <?php get_sidebar(); ?>
<?php endif; ?>
<?php get_footer(); ?>

Hi there,

This is actually a matter of the ACF and is not related to Cornerstone. You will need to consult with the documentation of the ACF.

I did a Google Search and found interesting results.

Thank you.