• Resolved Fabio Ceccarelli

    (@ilpiubello)


    Hi,
    I’m trying to add a custom item as last option of my dynamic select but is very difficult for me ??

    This is my function:

    function cf7_dynamic_select() {
    	$output = array();
    	$args = array(
    		'post_type' => 'page',
    		'post_parent' => '1331',
    		'order'=> 'ASC',
    		'orderby'=> 'menu_order',
    		'hide_empty' => 0 );
    
    	// this is my attemp to add last item
    	array_push($args, "altro", "altro");
    
    	$the_query = new WP_Query( $args );
    
    	while ( $the_query->have_posts() ) :
    		$the_query->the_post();
    		$output[get_the_title()] = get_the_title();
    	endwhile;
    	return $output;
    }
    add_filter('my-filter', 'cf7_dynamic_select', 10, 2);

    and this is my tag:
    [dynamicselect* service id:service "my-filter post_type=page post_parent=1331"]

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author John Huebner

    (@hube2)

    
    function cf7_dynamic_select() {
    	$output = array();
    	$args = array(
    		'post_type' => 'page',
    		'post_parent' => '1331',
    		'order'=> 'ASC',
    		'orderby'=> 'menu_order',
    		'hide_empty' => 0 );
    
    	$the_query = new WP_Query( $args );
    
    	while ( $the_query->have_posts() ) :
    		$the_query->the_post();
    		$output[get_the_title()] = get_the_title();
    	endwhile;
    
    	// add another item at end
    	$output['altro'] = 'altro';
    
    	return $output;
    }
    add_filter('my-filter', 'cf7_dynamic_select', 10, 2);
    
    Thread Starter Fabio Ceccarelli

    (@ilpiubello)

    Thank you John Huebner, is perfect ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add custom item to dynamic select’ is closed to new replies.