• Resolved Adam

    (@appsynergy)


    Hi there,

    I’m making a fairly complex form layout.

    Every time I make a change to my code, I need to copy and paste the new layout into the **Form** tab of **Edit Contact Form** and save, which is a little tiresome.

    Is it possible to skip this step, and have the form content load directly from a html file in the theme, for example?

    Thanks, A

Viewing 3 replies - 1 through 3 (of 3 total)
  • anonymized-15380454

    (@anonymized-15380454)

    Try this code (add it to the theme’s functions.php file, or you can use My Custom Functions or similar plugin):

    add_filter( 'wpcf7_contact_form_properties', function( $props, WPCF7_ContactForm $form ) {
    	// Set this to the form ID in the database.
    	$form_id = 1722;
    	// Set the full path of the template file.
    	$path = ABSPATH . 'wp-content/cf7-form-template.html';
    
    	if ( $form_id == $form->id() && @is_file( $path ) ) {
    		$props['form'] = @file_get_contents( $path );
    	}
    
    	return $props;
    }, 10, 2 );
    Thread Starter Adam

    (@appsynergy)

    Ah awesome, there’s a filter for it. Must have missed that. Thanks Sally!

    anonymized-15380454

    (@anonymized-15380454)

    No problem. ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can the Form content load directly from a file?’ is closed to new replies.