【发布时间】:2021-11-02 08:13:12
【问题描述】:
我们想在wp_include/functions.php 中添加shortcode 的自定义函数。
这是函数:
function url_id() {
$apiUrl = 'https:exampleurl.api.com/exemple123';
$response = wp_remote_get($apiUrl);
return wp_remote_retrieve_body($response);
}
add_shortcode('session_id', 'url_id');
但是我们收到了这个错误:
本网站出现严重错误。 详细了解如何对 WordPress 进行故障排除。
在阅读了更多故障排除文档后,我们在wp-config 中添加了这两行:
define( 'WP_DEBUG', true );
define( 'WP_CACHE', true );
然后我们得到这个错误:
致命错误:未捕获错误:调用 /home/c1624672c/public_html/woo/wp-includes/functions.php:18 中的未定义函数 add_shortcode() 堆栈跟踪:#0 /home/c1624672c/public_html/woo/wp -settings.php(111): require() #1 /home/c1624672c/public_html/woo/wp-config.php(104): require_once('/home/c1624672c...') #2 /home/c1624672c/ public_html/woo/wp-load.php(50): require_once('/home/c1624672c...') #3 /home/c1624672c/public_html/woo/wp-blog-header.php(13): require_once(' /home/c1624672c...') #4 /home/c1624672c/public_html/woo/index.php(17): require('/home/c1624672c...') #5 {main} 抛出 /home/c1624672c /public_html/woo/wp-includes/functions.php 第 18 行
本网站出现严重错误。详细了解 WordPress 疑难解答。
【问题讨论】:
标签: wordpress wordpress-theming custom-wordpress-pages wordpress-shortcode