start_controls_section( 'content_section', array( 'label' => esc_html__( 'Accordion Settings', 'accordions-wp' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ) ); // Fetch published post type 'accordion_tp' to match your shortcode $accordions = get_posts( array( 'post_type' => 'accordion_tp', 'posts_per_page' => -1, 'post_status' => 'publish', ) ); $options = array( '' => esc_html__( 'Select Accordion', 'accordions-wp' ) ); if ( ! empty( $accordions ) ) { foreach ( $accordions as $accordion ) { $options[ $accordion->ID ] = $accordion->post_title; } } $this->add_control( 'accordion_id', array( 'label' => esc_html__( 'Select Accordion', 'accordions-wp' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => '', 'options' => $options, 'description' => esc_html__( 'Choose an accordion created with TCP Accordion.', 'accordions-wp' ), ) ); $this->end_controls_section(); } /** * Render widget output on the frontend. */ protected function render() { $settings = $this->get_settings_for_display(); $accordion_id = ! empty( $settings['accordion_id'] ) ? absint( $settings['accordion_id'] ) : 0; // Show a helpful placeholder in the Elementor Editor if no ID is selected yet if ( ! $accordion_id ) { if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) { echo '
' . esc_html__( 'Please select an accordion from the left widget panel.', 'accordions-wp' ) . '
'; echo '