![]() |
Fetch contact-form-7 id to another plugin |
How to fetch contact-form-7 forms ID, to another plugin?
I want to get forms id and using that id, I will give some effect to that form, please tell me how to fetch form id from contact-form-7, to another plugin in wordpress.
Solution code for : Fetch contact-form-7 id to another plugin
Actually in contact form 7,the post type is wpcf7_contact_form So you can use this bellow code . In tis code the function return an array of all contact form's id.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | function get_cf7_IDS(){ $cf7_id_array = array (); if ( post_type_exists( 'wpcf7_contact_form' ) ) { $args = array ( 'post_type' => 'wpcf7_contact_form' , 'posts_per_page' =>-1, ); $the_query = new WP_Query( $args ); if ( $the_query ->have_posts() ) { while ( $the_query ->have_posts() ) { $the_query ->the_post(); $cf7_id_array []= get_the_ID(); } wp_reset_postdata(); } } return $cf7_id_array ; //RETURN THE ARRAY OF IDS } |
No comments:
Post a Comment