【发布时间】:2013-05-28 20:42:41
【问题描述】:
这个问题快把我逼疯了。
今天早上,我正在创建的 Wordpress 主题包含一个非常简单的 functions.php 文件,并且我的网站运行正常。今天,我编写了一个新函数来遍历类别并列出某些帖子,这是我对 functions.php 所做的唯一更改。
将修改后的函数文件上传到服务器后,每次访问我的站点时都会收到 500 错误。我虽然,“好吧,我的新函数破坏了一些东西。我将把它从functions.php中删除并重新开始。”但是,在恢复到文件的原始版本(今天早上工作的版本)后,我仍然收到 500 错误。
如果我从服务器中删除 functions.php,我的页面会加载(显然没有侧边栏,但它们会加载)。一旦我再次上传文件(与今天早上工作的版本相同),我就会收到 500 错误。
我检查了错误日志,发现当我在服务器上有functions.php 时,Wordpress(或者更可能是php)无法再找到get_template_directory_uri() 函数。我没有做任何改变任何标准 Wordpress 函数的事情,而且只有在我上传了 functions.php 时才会发生这种情况。
什么可能导致functions.php破坏标准函数?
这是我的functions.php文件:
<?php
/* *********************************************
* Create left-hand sidebar for single.php
*
* TODO: Finalize $sricks_single_left_sidebar.
* ********************************************/
$sricks_single_left_sidebar = array(
'name' => 'Left Sidebar',
'id' => 'lt-single',
'description' => 'This is the sidebar on the left side of the single.php template page.',
'before_widget' => '<!-- Left-Single Sidebar --><div class="lt-single">',
'after_widget' => '</div> <!-- End Left-Single Sidebar -->',
'before_title' => '<h1>',
'after_title' => '</h1>',
);
register_sidebar( $sricks_single_left_sidebar );
/* *********************************************
* Create header_search sidebar to be used on
* all pages
* ********************************************/
$sricks_header_search_sidebar = array(
'name' => 'Header Search',
'id' => 'header-search',
'description' => 'This is the search box in the page header.',
'before_widget' => '<!-- Header-Search Sidebar --><div class="header-search">',
'after_widget' => '</div> <!-- End Header-Search Sidebar -->',
'before_title' => '<h1>',
'after_title' => '</h1>',
);
register_sidebar( $sricks_header_search_sidebar );
?>
【问题讨论】:
-
您的
functions.php文件没有问题。它必须是别的东西。打开调试并告诉我输出是什么。编辑wp-config.php并将其放入:define( 'WP_DEBUG', true ); -
谢谢,斯宾塞卡梅隆。启用调试后,我发现了问题的原因。由于我是新人,我还有 7 个小时无法回答我自己的问题,但到时候我会更新答案。
-
我很高兴这有帮助。我会给出关于
WP_DEBUG的答案,因为这说明了您的问题的原因。
标签: wordpress wordpress-theming