Home Forums Backend Issues (wp-admin) Display field from another CPT


Display field from another CPT

  • Hi,

    This is my case:

    My CPT#1 : Incident report
    (with fields like NAME of PART DAMAGED, …)

    My CPT#2: Reparation task
    with a relationship field to CPT#1 Incident report.

    As they are “linked”, in the WP admin listof CPT#2, how can i display a column with field from CPT#1 (NAME of PART DAMAGED) set in CPT#1 ?

    I hope i am clear enough, sorry for my bad english…

  • You need to do a reverse relationship query in CPT2 to get the post for CPT1

    $args = array(
      'post_type' => 'CPT#2',
      'posts_per_page' => '1', // assuming there is only one
      'meta_query' => array(
          'key' => 'RELATIONSHIP_FIELD_NAME',
          'value' => '"'.$post->ID.'"',
          'compare' => 'LIKE'
    $query = new WP_Query($args);
    if ($query->have_posts) {
      $related_id = $query->posts[0]->ID;
      // get field from the other post
      $value = get_field('some other field', $related_id);

    see this page for more on reverse relationship queries

  • thanks a lot John, but is it possible to have these fields (from CPT#1) in the backend list (and in the CPT#2 form in read only) ? Using AdminColumnPro ?

    Should i also use


  • I don’t know if my plugin will help or not. And I also can’t give any advice on the other plugin. You’re trying to display information from another post in the admin list, unless the other plugin gives you an option to do this then I would say no, even if you have my plugin installed. You need to find out from the other plugin if you can show data from a related post.

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

The topic ‘Display field from another CPT’ is closed to new replies.