Support

Account

Home Forums General Issues Show Custom Field results from one post type in template of another Reply To: Show Custom Field results from one post type in template of another

  • Hi @andisaleh and @elliot

    I feel this is getting closer but still can’t work out why such a simple task of grabbing one value from another post and matching it to current post is so hard. I am going crazy! haha.

    New query is now this, but unfortunately it returns nothing.

    <?php
    $args = array(
      'numberposts'=> -1,           // Fetch all posts...
      'post_type'=> 'release',      // from the 'release' CPT...
      'meta_key' => 'artist_name', // which inside this meta key...
      'meta_value' => get_the_ID(),   // has this meta value.
    );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) :
      echo '<ul>';
      while ($my_query->have_posts()) : $my_query->the_post();
    ?>
    <li>
    <img src="<?php the_field('cover_image'); ?>" />
    <?php the_field('artist_name'); ?>
    <?php the_title(); ?>
    </li>
    
    <?php 
    endwhile; echo '</ul>';
    endif; wp_reset_query(); ?>

    Failing this – do either of you know any quick places I can go to pay someone to do this? I just don’t have any contacts in that regard.