Elementor cpt select

function elementor_cpt_list( ) {

	$args = wp_parse_args( array(
		'post_type'   => 'cpt',
		'numberposts' => -1,
		'orderby' => 'title',
		'order' => 'ASC',
	) );

	$query_query = get_posts( $args );

	$dropdown_array = array();
	if ( $query_query ) {
		foreach ( $query_query as $query ) {
			$dropdown_array[ $query->ID ] = $query->post_title;
		}
	}

	return $dropdown_array;
}

Leave a Reply