Skip Navigation

[Resolved] bootstrap broke contact form 7 forms

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 2 replies, has 2 voices.

Last updated by Miguel 1 year, 11 months ago.

Author
Posts
#2556093
bootstrap disabled.png
bootsrap enabled.png

Tell us what you are trying to do?
I'm using Genesis theme form my site.
I have some contact form 7 in my site.
I added some Toolset forms to create cpts.
I enabled Bootstrap 3 or 4 in Toolset Settings

Problem: contact form 7 don't look as I made them.

Is there any documentation that you are following?
I couldn't find similar problem.

Is there a similar example that we can see?

What is the link to your site?
local

#2556495

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Miguel

You have Bootstrap enabled within Toolset settings because you want Toolset form elements (either forms made with Toolset, or filter controls, pagination links etc. of Views to benefit from Bootstrap styling), yes?

But adding Bootstrap affects the styling of your Contact Form 7 forms, correct?

While it is not possible within the settings to only enable Bootstrap on certain pages, one solution would be to dequeue the Bootstrap assets on specific pages (where you have added a Contact Form 7).

See here for an example of code to do that; you would need to modify it so that it takes effect only on the pages you specify (using is_page):

hidden link

See: https://developer.wordpress.org/reference/functions/is_page/

#2556535

Ah!! Great!
I added the snippet to theme functions.php

/**
 * Don't enqueue Bootstrap on "Qué es la SAR" y "Contáctenos" pages
 */
function dequeue_bootstrap(){

if ( is_page( array( 'que-es-la-sar', 'contactenos' ) ) ){

    // dequeue Bootstrap CSS
    function dequeue_bootstrap_css(){
      wp_dequeue_style( 'toolset_bootstrap_styles' );
      wp_dequeue_style( 'toolset_bootstrap_4' );
    }
    add_action( 'wp_print_styles', 'dequeue_bootstrap_css' );

    // dequeue Bootstrap JS 
    function dequeue_bootstrap_js(){
      wp_dequeue_script( 'toolset_bootstrap' );
      wp_dequeue_script( 'toolset_bootstrap_4' );
    }
    add_action( 'wp_print_scripts', 'dequeue_bootstrap_js' );    

  }

}
add_action( 'wp_enqueue_scripts', 'dequeue_bootstrap', 100 );


And worked perfectly!

Thank you!!