如何在页面返回到浏览器之前将一些 php 代码动态添加到页面中的确切位置?
我需要在使用 PHP 的 wp_head();
调用之前添加这段代码,因为代码必须在服务器端执行。将代码挂接到我的 wp_head();
中不起作用。我需要在之前添加它。这是要添加的 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 片段添加到这个确切位置?
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_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(); ?>
The code should not show on return to browser. How do I add this PHP snippet to this exact location dynamically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我实际上需要:
不是
,事实证明我只需要找到正确的钩子来添加动作。
I actually needed to :
not
I turns out I just needed to find the right hook to add_action to.