ReCaptcha not working when get_header(); called after content
-
ReCaptcha not working when
get_header()
called afterget_template_part( 'template-parts/content')
.In many themes
get_header()
called after generating content for different reasons (in our case we want to use wp_enqueue_script/wp_enqueue_style in parts).
Example forsingular.php
change:<?php /** * The template for displaying single posts and pages. * * @link https://developer.www.ads-software.com/themes/basics/template-hierarchy/ * * @package WordPress * @subpackage Twenty_Twenty * @since Twenty Twenty 1.0 */ ob_start(); ?> <main id="site-content" role="main"> <?php if ( have_posts() ) { while ( have_posts() ) { the_post(); get_template_part( 'template-parts/content', get_post_type() ); } } ?> </main><!-- #site-content --> <?php get_template_part( 'template-parts/footer-menus-widgets' ); ?> <?php $content = ob_get_clean(); ?> <?php get_header(); ?> <?php echo $content ?> <?php get_footer(); ?>
Issue caused by this code:
if ( ! wp_script_is( 'google-recaptcha', 'registered' ) && function_exists( 'wpcf7_recaptcha_enqueue_scripts' ) ) { wpcf7_recaptcha_enqueue_scripts(); }
So it enqueues default CF url for ‘google-recaptcha’.
Please fix this by calling
iqfix_wpcf7_recaptcha_enqueue_scripts()
if recaptcha v2 is enabled.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘ReCaptcha not working when get_header(); called after content’ is closed to new replies.