【问题标题】:Wordpress - white screen of death when trying to update a page and/or a file in EditorWordpress - 尝试在编辑器中更新页面和/或文件时出现白屏死机
【发布时间】:2017-10-16 19:47:11
【问题描述】:

我正在使用 html5blank 的子主题将前端站点加载到 wordpress 上,并且我得到了白屏处理 - 奇怪的是(或不是?)我只有在点击更新按钮时才得到它页面或当我从外观>编辑器中点击“更新文件”时。

我相信我已经完成了所有标准检查 - 插件、主题(如果是主题,为什么我什至可以访问?)。我查看了 phpmyadmin 并在那里看不到任何东西。

这就是我在functions.php 中的内容 -

<?php
function my_theme_enqueue_styles() {

    $parent_style = 'html5blank-style'; // This is 'html5blank-style' for the HTML 5 Blank theme.

    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style ),
        wp_get_theme()->get('Version')
    );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>

我刚刚开始构建网站 - 我在插件面板中只有 Akismet 和 Hello Dolly,它们都没有被激活。任何人都可以在 functions.php 中发现我看不到的东西还是我需要检查的其他东西?

【问题讨论】:

    标签: php wordpress html


    【解决方案1】:

    在进行了更深入的搜索后,我发现了这个 article - 并通过将这个代码添加到我的 wp-config.php 文件中来听取建议 -

    error_reporting(E_ALL); ini_set('display_errors', 1);
    
    define( 'WP_DEBUG', true);
    

    此代码将您指向空白处的错误,在我的情况下,它与我的functions.php 文件中的太多空白有关。这个article 帮助我解决了这个问题。现在一切正常。

    【讨论】:

      【解决方案2】:

      如果您有一个带有 style.css 和 functions.php 的简单子主题,并且例如如果您更新帖子或尝试在自定义期间更改/加载其他主题而不是打开您的 functions.php,则会出现白屏在您的子主题目录中。删除所有空格和所有行。之后它将起作用。

      白屏错误的儿童主题:

      <?php 
      
      add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
      
      function theme_enqueue_styles() 
      {
          wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
          wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array('parent-style') );        //Comment with to much white space
      }
      
      ?>
      

      没有错误的新子主题

      <?php 
      add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
      function theme_enqueue_styles() 
      {
          wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
          wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array('parent-style') );//Comment updated without space
      }
      ?>
      

      顺便说一句:我有第二行,因为第一行我无法覆盖原始 style.css。第二行有助于在没有其他任何东西的情况下做到这一点。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多