wordpress - Get Field values from another post type with ACF relationship -


i'm using following code list of post titles set acf relationship. question how custom field values on other post type. (i can post meta info @ moment)

<form id="course-drop" name="course-drop" class="wpcf7-form" method="get" action=""> <select name="provider" id="provider" class="form-control">     <option value="">---</option>     <?php         $course_providers = get_posts(array(             'post_type' => 'course_providers',             'meta_query' => array(                 array(                 'key' => 'courses_offered',                 'value' => '"' . get_the_id() . '"',                 'compare' => 'like'                 )             )         ));     ?>      <?php if( $course_providers ): ?>         <?php foreach( $course_providers $course_provider ): ?>             <option value="<?php echo get_the_title( $course_provider->id ); ?>" data-email="<?php echo the_field('email_address'); ?>"><?php echo get_the_title( $course_provider->id ); ?></option>         <?php endforeach; ?>     <?php endif; ?>  </select> 

check data attribute have tried need email.

ref used: https://www.advancedcustomfields.com/resources/querying-relationship-fields/

you can use following custom field of post.

<?php echo the_field('email_address', 123); ?>  //replace post id 123 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -