Search code examples
phpwordpresscontact-formcontact-form-7

Contact Form 7 fields list by form id?


How can I get all "Contact Form 7" fields as object by a form id?

There is a function who do that? Do I need to take the content of the post and handle it with the regex?

Thanks.


Solution

  • Contact Form 7 forms are just posts with a custom post type of wpcf7_contact_form. The form fields are saved as html (with shortcodes) as post meta with a key of _form. In order to get this data, you can use get_post_meta().

    Again...this won't actually return the rendered html fields...just the shortcodes and other form layout. The actual form fields aren't rendered until WPCF7 runs do_shortcode().