Search code examples
javascriptwordpresspluginsconsolecontact-form-7

Cannot read property 'querySelector' of null - WordPress / Contact Form 7


Seem to be getting an error on our contact forms on version 5.4.1 and the version before using the Contact Form 7 plugin on WordPress. The error occurs when submitting the form regardless of entering information or not. The error which appears in console is as follows:

TypeError: Cannot read property 'querySelector' of null
at c (index.js?ver=5.4.1:1)
at Array.forEach (<anonymous>)
at index.js?ver=5.4.1:1

Read a couple of articles about rolling back to version 5.3.2 which I can confirm works and the issue isn't present in this version. Does anyone have a fix for it though? Or do we need to wait for another update? It's been a couple of weeks now since this was first found I believe.

If anyone needs any other information please let me know and I'll try to supply it.

Thanks!


Solution

  • You can edit

    define( ‘WPCF7_LOAD_JS’, true );
    

    to

    define( ‘WPCF7_LOAD_JS’, false );
    

    on wp-contact-form-7.php file.