Home Forums Backend Issues (wp-admin) Get email field from custom post type to product post


Get email field from custom post type to product post

  • Hi,

    I’m trying to get the Email field to my Product post type from a related Seller post type Email field.

    I have two post types Seller and Product.

    Seller post type has custom fields:

    • Bi-directional relationship field to Products so seller is linked to products
    • Email field
    • Telephone, address etc…

    Product post type with fields:

    • Bi-directional relationship field to Seller
    • Email field (I would like this to fetched from the related Seller post type)
    • Additional product information etc…

    I’ve looked at multiple examples about post relationships and fields but I haven’t found any examples on how to get a specific field from a related post and display/attach it to a post in the backend.

    Any suggestions on where to start or is this even possible?

    I think this might be a starting point.

    The only thing is that I don’t think this will work in the backend.

    $post_object = get_field('project_name');
    if( $post_object ): ?>
        	<h4><?php echo get_the_title($post_object->ID); ?></h4>
            <span>Post Object Custom Field: <?php the_field('project_description', $post_object->ID); ?></span>
        <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    <?php endif; ?>
  • Hi olppa,

    Have you found a solution for this problem?


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

You must be logged in to reply to this topic.