【问题标题】:Fatal error: Call to undefined function get_header() in /home/theun3wr/public_html/author.php on line 11致命错误:在第 11 行的 /home/theun3wr/public_html/author.php 中调用未定义函数 get_header()
【发布时间】:2016-03-03 19:58:34
【问题描述】:

自从我在 12 月转向多域托管以来,我的网站上出现了错误。有太多的问题,我已经忘记了它们。每天我都会遇到一个令人震惊的新错误,我对此一无所知。

最近的一个无法访问我网站上的作者资料 - http://www.theunbiasedblog.com/author/nikhil

网站的其他部分工作正常,除了以下几点:

  1. 作者简介(上面提到)这个错误

    Fatal error: Call to undefined function get_header() in /home/theun3wr/public_html/author.php on line 11
    
  2. 网站上的标记链接 (http://www.theunbiasedblog.com/tag/windows) 出现此错误

    Fatal error: Call to undefined function get_header() in /home/theun3wr/public_html/tag.php on line 11
    
  3. 网站上的类别链接 (theunbiasedblogcom/category/tech)

    Fatal error: Call to undefined function get_header() in /home/theun3wr/public_html/category.php on line 11
    

我无法弄清楚如何处理所有这些非功能链接的第 11 行上的 get_header()。结果,我收到了来自 google 的 30K 404 错误。

@prakashrao 在 wp-includes/general-template.php 中

我有这个-

 /**
 * Load header template.
 *
 * Includes the header template for a theme or if a name is specified then a
 * specialised header will be included.
 *
 * For the parameter, if the file is called "header-special.php" then specify
 * "special".
 *
 * @since 1.5.0
 *
 * @param string $name The name of the specialised header.
 */
  function get_header( $name = null ) {
  /**
 * Fires before the header template file is loaded.
 *
 * The hook allows a specific header template file to be used in place of the
 * default header template file. If your file is called header-new.php,
 * you would specify the filename in the hook as get_header( 'new' ).
 *
 * @since 2.1.0
 * @since 2.8.0 $name parameter added.
 *
 * @param string $name Name of the specific header file to use.
 */
do_action( 'get_header', $name );

$templates = array();
$name = (string) $name;
if ( '' !== $name )
    $templates[] = "header-{$name}.php";

$templates[] = 'header.php';

// Backward compat code will be removed in a future release
if ('' == locate_template($templates, true))
    load_template( ABSPATH . WPINC . '/theme-compat/header.php');
 }

【问题讨论】:

    标签: wordpress get-headers


    【解决方案1】:

    确保你在你的活动主题中定义了这个函数

    function get_header( $name = null ) {
        /**
         * Fires before the header template file is loaded.
         *
         * The hook allows a specific header template file to be used in place of the
         * default header template file. If your file is called header-new.php,
         * you would specify the filename in the hook as get_header( 'new' ).
         *
         * @since 2.1.0
         * @since 2.8.0 $name parameter added.
         *
         * @param string $name Name of the specific header file to use.
         */
        do_action( 'get_header', $name );
    
        $templates = array();
        $name = (string) $name;
        if ( '' !== $name )
            $templates[] = "header-{$name}.php";
    
        $templates[] = 'header.php';
    
        // Backward compat code will be removed in a future release
        if ('' == locate_template($templates, true))
            load_template( ABSPATH . WPINC . '/theme-compat/header.php');
    }
    

    【讨论】:

    • 在你的活动主题的functions.php中
    • 致命错误:无法在 /home/theun3wr/public_html/wp-includes/general 中重新声明 get_header()(之前在 /home/theun3wr/public_html/wp-includes/functions.php:8 中声明) -template.php 第 49 行
    • 你能提供一张你上传到服务器的目录结构的屏幕截图吗.. 以及 wp-content 中的一个屏幕截图
    • 非常感谢您花费时间和精力来帮助我。非常感谢你,如果我能为你做任何事,请告诉我。
    猜你喜欢
    • 2011-04-19
    • 1970-01-01
    • 2012-04-21
    • 2012-04-21
    • 2019-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多