在wordpress中加载header.php之前如何运行shortcode? [英] How run shortcode before loading header.php in wordpress?

查看:148
本文介绍了在wordpress中加载header.php之前如何运行shortcode?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

人。当我的短代码无法正常工作时,如果我在标题中添加短代码,我有一些情况,因为首先加载header.php并且仅在加载短代码之后。
如何在加载header.php之前运行shortcode?
我尝试使用hoocks,但找不到解决方案。
最好的问候。

解决方案

如果您想在标头之前运行代码。 php 已加载,您可以使用 get_header 钩子:

 函数run_before_header($名){
do_shortcode ...
}
ADD_ACTION( 'get_header', 'run_before_header');


guys. I have some situation when my shortcode don't work correctly, if I add shortcode in header, because first of all load header.php and only after that load my shortcode. How can I run shortcode before loading header.php ? I try to use hoocks, but not find solution. Best regards.

解决方案

If you want to run your code just before your header.php is loaded you can use the get_header hook:

function run_before_header( $name ) {
    do_shortcode...
}
add_action( 'get_header', 'run_before_header' );

这篇关于在wordpress中加载header.php之前如何运行shortcode?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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