Support

Account

Forum Replies Created

  • Hi Edd,

    Thats great news. Thanks for the help.

    Now that I know it’s possible I’ll invest some time setting it up. It’s a bit beyond my ACF experience but I’ll see what I can do.
    Thanks again.

  • Hi John,

    You’re a genius. Thank you. It’s working perfectly.

    Below is my final code for anyone else needing this fix. Note: I’ve added a hyperlink around the logo to the relevant post.

    <?php $args = array(
      				'post_type' => 'post', // or your post type
      				'posts_per_page' => -1, // get them all
      				'meta_query' => array(
        				array(
          				'key' => 'logo',
          				'value' => '',
          				'compare' => '!='
        				) ) );
    				$query = new WP_Query($args);
    				if ($query->have_posts()) {
    				global $post;
    				while ($query->have_posts()) {
    				$query->the_post();
    					echo '<a href="' . get_permalink() . '">';
    					echo '<img src="' . get_field('logo') . '" /></a>';
      				}
      				wp_reset_postdata();
    				}
    				?>
  • Thanks John.
    I’m getting closer but having issues outputting the image.
    My echo code must be wrong. Any ideas?

    <?php
    $args = array(
      'post_type' => 'post', // or your post type
      'posts_per_page' => -1, // get them all
      'meta_query' => array(
        array(
          'key' => 'logo',
          'value' => '',
          'compare' => '!='
        )
      )
    );
    $query = new WP_Query($args);
    if ($query->have_posts()) {
      global $post;
      while ($query->have_posts()) {
        $query->the_post();
    	echo '<img src="' . the_field('logo') . '"></img>';
      }
      wp_reset_postdata();
    }
    ?>
Viewing 3 posts - 1 through 3 (of 3 total)