Reputation: 98
I have created elementor SELECT control that shows all post from 'post_type' => 'digital_card' now I want to display the ACF field from the selected post my ACF field name is business_name
$options = array();
$posts = get_posts( array(
'post_type' => 'digital_card'
) );
foreach ( $posts as $key => $post ) {
$options[$post->ID] = get_the_title($post->ID);
}
$this->add_control(
'card_title',
[
'label' => __( 'Select Posts', 'plugin-domain' ),
'label_block' => ('bool'),
'type' => \Elementor\Controls_Manager::SELECT,
'multiple' => true,
'options' => $options,
]
);
<h1><?php the_field('business_name', want to pass selected id here ); ?></h1>
Upvotes: 0
Views: 731
Reputation: 47
you need to create function for example
get_selected_post(){
$settings = $this->get_settings_for_display();
$selectedOption=$settings('card_title');
return $selectedOption
}
then call the function in your control
'default'=>self::get_selected_post()
Upvotes: 0