top of page

Dynamic Values in Contact Form 7 Fields

  • Writer: سُلَيْمَان بْن دَاوُوْد
    سُلَيْمَان بْن دَاوُوْد
  • Feb 16, 2021
  • 1 min read


add_filter('wpcf7_form_tag_data_option', 'contact_dynamic_values' , 10, 3);

function contact_dynamic_values($n, $options, $args) {
  if (in_array('gigs', $options)){

  	$args = array(	'post_type'      	=> 'products',
					'posts_per_page' 	=> -1,
					'post_status'    	=> 'publish'
				);

  	$loop = new WP_Query($args);

  	$products[''] ='Select Product'; 
	if($loop->have_posts()){
		while ($loop->have_posts()) {
			$loop->the_post();

  			$products[get_the_title()] =get_the_title()  ;
  		}
  	}
    
    
    return $products;
  }
  return $n;
}




 
 
 

Recent Posts

See All
Duplicate Category in Wordpress

The following code helps to duplicate the default wordpress category by help of code. // Add Duplicate option for categories in WordPress...

 
 
 
C#.NET and Its Associated Codes

1- Creating an Desktop Application in C#.NET C# ADO.NET & MySQL MAIN C# and MySQL ADO.NET with Crystals Reports Ready Code 2- Handling...

 
 
 

Comments


© 2020 by syednazrulhassan

bottom of page