开发者

How do I dynamically add some piece of php code to an exact position in page before it is returned to the browser?

I need to add this piece of code right before my wp_head(); call using PHP because the code has to execute server side. Hooking the code into my wp_head(); does not work. I need to add it right before. Here is the PHP code to be added.

gravity_form_enqueue_scripts(1,true);

Here is where the code needs to be inserted:

<?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_enque开发者_运维技巧ue_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(); ?>

The code should not show on return to browser. How do I add this PHP snippet to this exact location dynamically?


I actually needed to :

add_action('wp', 'gforms_add_before_wp_head');

not

add_action('wp_head', 'gforms_add_before_wp_head');

I turns out I just needed to find the right hook to add_action to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜