重力形式添加不显示 [英] Gravity Forms adding display none

查看:58
本文介绍了重力形式添加不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在WordPress主题内创建一个自定义模板,因为我的模板与活动主题的布局完全不同,因此该模板具有自己的标头&页脚和内部都分别正确声明了 wp_head(); wp_footer(); .

I'm creating a custom template inside my WordPress theme, since my template is a completely different layout than my active theme, the template has it's own header & footer and inside of both I have properly declared wp_head(); and wp_footer(); respectively.

在我的模板代码中,我试图使用do_shortcode显示重力形式,但没有形式显示.当我检查该区域时,可以看到表单代码,但是在 .gform_wrapper div中添加了 style ="display:none" .

Inside my template code, I am trying to display a gravity form using do_shortcode, but no form shows. When I inspect the area, I can see the form code, but there is a style="display:none" added to the .gform_wrapper div.

还有一点需要注意,重力形式在我网站的其余部分(使用活动主题的所有页面/帖子)中都能正常工作,我的自定义模板上只有这个问题.

As one more note, gravity forms is working perfectly throughout the rest of my site (all pages/posts using the active theme), I only have the problem on my custom template.

任何建议都值得赞赏.

谢谢

推荐答案

尽管这是一个老问题,但是当我搜索此问题时仍然会首先出现,因此我添加了解决方案,以防其他人也在搜索.如果您的主题通过在functions.php中包含以下一行或多行代码来将脚本移至页脚(出于性能方面的原因而经常建议使用此脚本):

Although this is an old question it still came up first when I searched for this problem, so I'm adding my solution in case others are searching too. If your theme moves scripts to the footer (frequently recommended for performance reasons) by including one or more of the following lines of code in functions.php:

remove_action('wp_head', 'wp_print_scripts'); 
remove_action('wp_head', 'wp_print_head_scripts', 9);
add_action('wp_footer', 'wp_print_scripts', 5);
add_action('wp_footer', 'wp_print_head_scripts', 5);

您还需要将Gravity Forms脚本移至页脚,以便在jQuery之后调用它们.您可以通过在主题的functions.php文件中添加以下代码来做到这一点:

you'll need to move the Gravity Forms scripts to the footer as well, so they get called after jQuery. You can do this by adding the following code to your theme's functions.php file:

add_filter('gform_init_scripts_footer', 'init_scripts');
function init_scripts() {
    return true;
}

这篇关于重力形式添加不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆