functions.php会导致白屏和媒体库问题

时间:2014-11-24 14:15:02

标签: wordpress woocommerce

我在function.php

中禁用所有插件,所有空格和php注释

但问题没有解决。

当我删除function.php中的所有代码时问题已解决,但如果在文件中写<?php ?>则问题返回

functions.php导致白屏和媒体库未加载。这里是function.php

<?php
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10);
add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10);
function my_theme_wrapper_start() { echo '<section class="header">'; }
function my_theme_wrapper_end() { echo '</section>'; }
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 70, 150 );
function register_my_menu() {
  register_nav_menu('header-menu',__( 'Header Menu' ));
}
add_action( 'init', 'register_my_menu' );
add_filter( 'add_to_cart_text', 'woo_custom_cart_button_text' );                        
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_custom_cart_button_text' );
function arphabet_widgets() {
    register_sidebar( array(
        'name' => 'sidebar',
        'id' => 'right-panel',
        'before_widget' => '<div class="panel">',
        'after_widget' => '</div>',
        'before_title' => '<h2 class="title">',
        'after_title' => '</h2>',
    ) );
}
add_action( 'widgets_init', 'arphabet_widgets' );
function search() {

    register_sidebar( array(
        'name' => 'search',
        'id' => 'search-panel',
        'before_widget' => '<div class="panel">',
        'after_widget' => '</div>',
        'before_title' => '<h2 class="title">',
        'after_title' => '</h2>',
    ) );
}
add_action( 'widgets_init', 'search' );
add_theme_support( 'woocommerce' );
?>

如何解决?!

1 个答案:

答案 0 :(得分:2)

尝试删除PHP结束标记?&gt;来自文件functions.php。这是不必要的,我遇到过这样的情况,即&#34;?&gt;&#34; -tag后面的空白/换行会导致WordPress抛出一个空白屏幕,因为标题发送得太早/多次(已发送标题)。