繁体   English   中英

如何添加自定义 php 函数并在我的 wordpress 主题中调用它们?

[英]How can I add custom php functions and call them in my wordpress theme?

我正在开发一个自定义 Wordpress 主题,我创建了两个 php 文件,其中包含一个自定义 function,必要时可以调用。 在本地主机(带有 wordpress 和 mysql 的 docker 容器)中工作时,一切都按预期工作,但是当我将文件上传到另一个 wordpress 实例时,我想到了这个:

Fatal error: Uncaught Error: Call to undefined function loader() in /var/www/vhosts/xxxx.es/httpdocs/wp-content/themes/xxxx/index.php:25 
Stack trace: #0 /var/www/vhosts/xxxx.es/httpdocs/wp-includes/template-loader.php(106): include() 
#1 /var/www/vhosts/xxxx.es/httpdocs/wp-blog-header.php(19): require_once('/var/www/vhosts...') 
#2 /var/www/vhosts/xxxx.es/httpdocs/index.php(17): require('/var/www/vhosts...') 
#3 {main} thrown in /var/www/vhosts/xxxx.es/httpdocs/wp-content/themes/xxxx/index.php on line 25

提前致谢

看起来你在 index.php 中调用了一个名为loader()index.php ,你没有定义它。 您需要将任何自定义函数添加到functions.php文件

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM