plugins – Update title field while listing wordpress page titles in Elementor selector

Question

I can get wordpress page list to elementor selector. I can get the pages as a list, but the title field remains as the page id. can someone help

$options = array();
$pages = get_pages(array(
));

foreach ($pages as $key => $page) {
    $options[$page->ID] = get_the_title($page->ID);
}


$repeater = new \Elementor\Repeater();

$repeater->add_control(
    'selected_item_id',
    [
        'label' => __('Portfolio Item', 'cabei'),
        'type' => \Elementor\Controls_Manager::SELECT,
        'options' => $options,
    ]
);


$this->add_control(
    'list',
    [
        'label' => esc_html__( 'Repeater List', 'cabei' ),
        'type' => \Elementor\Controls_Manager::REPEATER,
        'fields' => $repeater->get_controls(),
        'title_field' =>  '{{{ selected_item_id }}}',
    ]
);

Title field area show page id like below:

enter image description here

0
tavonline 2 months 2022-09-28T08:54:35-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse