简体   繁体   English

WordPress 中的“调用未定义函数”

[英]“Call to undefined function” in WordPress

I ran into problem but I couldn't resolve the issue.我遇到了问题,但我无法解决问题。 I read so many post and reset WordPress and using Xampp.我阅读了很多帖子并重置了 WordPress 并使用了 Xampp。 I don't know why everything is messed up.我不知道为什么一切都乱七八糟。 Build system even not showing php in sublime text 4.构建系统甚至没有在 sublime text 4 中显示 php。

When I ran my local host it gives:当我运行本地主机时,它给出:

错误 . .

My theme folder is here .我的主题文件夹在这里 I know there are questions have been asked but they are somehow different.我知道有人问过一些问题,但它们在某种程度上有所不同。

<h1><?php bloginfo('name') ?></h1>

This is because you're accessing your theme files from the browser.这是因为您正在从浏览器访问您的主题文件。 I can see from your URL that you're accessing your theme index.php file directly.我可以从您的 URL 中看到您正在直接访问您的主题index.php文件。 This is bypassing WordPress and the functions it makes available to you.这是绕过 WordPress 及其为您提供的功能。

Ensure your custom theme is active within the WordPress admin area, and then visit your WordPress website url: http://localhost/warda/wordpress/ .确保您的自定义主题在 WordPress 管理区域内处于活动状态,然后访问您的 WordPress 网站 URL: http://localhost/warda/wordpress/ This will load WordPress and then WordPress will load your theme.这将加载 WordPress,然后 WordPress 将加载您的主题。 You should no longer have the error.您应该不再有错误。


For example, suppose you have an index.php file that contains:例如,假设您有一个index.php文件,其中包含:

<?php

function custom_function() {
    echo 'Hello, World!';
}

require __DIR__ . '/extra.php';

And an extra.php file that contains:还有一个extra.php文件,其中包含:

<?php

custom_function();

If you open index.php in the browser it will register a function called custom_function , then load extra.php and then execute the function.如果您在浏览器中打开index.php ,它将注册一个名为custom_function的函数,然后加载extra.php并执行该函数。 It will output Hello, World .它将输出Hello, World

If you open extra.php in the browser, it will attempt to execute custom_function , but because it has not been defined yet, it will throw an "undefined function" error.如果你在浏览器中打开extra.php ,它会尝试执行custom_function ,但是因为它还没有被定义,它会抛出一个“undefined function”错误。

This is essentially what is happening with your WordPress theme.这基本上就是您的 WordPress 主题所发生的情况。

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

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