Home Forums Front-end Issues Displaying image in parent page


Displaying image in parent page

  • Hello everyone,

    I’m trying to display a image(image-1) of child pages inside of parent page, it’ll be a catalog. But it only returns on display “array” instead of link to field image-1. Can you explain what’s wrong here?

    					$mypages = get_pages( array( 'child_of' => $post->ID,'parent' => $post->ID, 'sort_column' => 'post_date','sort_order' => 'desc' ) );
    					foreach( $mypages as $page ) {		
    						$content = $page->post_content;
    						if ( ! $content )
    						$content = apply_filters( 'the_content', $content );
    					<div class="catalog">
    						<h2><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h2>
    						<?php echo get_the_post_thumbnail( $page->ID, 'subpage' ); ?>
    						<?php $field1 = get_field( 'field-1', $page->ID );
                            echo $field1; ?>
    						<img src="<?php $image = get_field( 'image-1', $page->ID );
                            echo $image; ?>">
    						<a href="<?php echo get_page_link( $page->ID ); ?>">more</a>
  • What do you have the image field set to return? It is probably set to “Image Object” or “Image Array” depending on what version of ACF you’re using. Either set it to return the Image URL or do

    <img src="<?php $image = get_field( 'image-1', $page->ID );
                            echo $image['url']; ?>">
  • I’m currently using free version(and object was chosen). Thank you so much for your input, worked like charm :3

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Displaying image in parent page’ is closed to new replies.