2011-02-08 20 views
1

我需要在使用PHP调用wp_head();之前添加这段代码,因为代码必须执行服务器端。将代码挂接到我的wp_head();不起作用。我需要在之前添加它。这里是要添加的PHP代码。如何在页面返回浏览器之前动态地将一段php代码添加到页面中的确切位置?

gravity_form_enqueue_scripts(1,true); 

这里是需要插入的代码:

<?php 

/* We add some JavaScript to pages with the comment form 
* to support sites with threaded comments (when in use). 
*/ 
if (is_singular() && get_option('thread_comments')) 
    wp_enqueue_script('comment-reply'); 

/* Always have wp_head() just before the closing </head> 
* tag of your theme, or you will break many plugins, which 
* generally use this hook to add elements to <head> such 
* as styles, scripts, and meta tags. 
*/ 

gravity_form_enqueue_scripts(1,true); 

wp_head(); ?> 

的代码不应该返回到浏览器显示。如何动态地将此PHP片段添加到此确切位置?

+0

是否可以通过jQuery和PHP的组合来实现? – 2011-02-08 05:09:23

回答

1

我确实需要:

add_action('wp', 'gforms_add_before_wp_head'); 

add_action('wp_head', 'gforms_add_before_wp_head'); 

我原来我只是需要找到合适的钩ADD_ACTION到。

相关问题