【问题标题】:Page not showing after add a function on child theme在子主题上添加功能后页面未显示
【发布时间】:2015-08-20 20:16:00
【问题描述】:

我使用 Genesis 框架和 modern-studio-pro 作为子主题。我刚刚复制了这段代码

function genesis_standard_loop() {

//* Use old loop hook structure if not supporting HTML5
if ( ! genesis_html5() ) {
    genesis_legacy_loop();
    return;
}

if ( have_posts() ) :

    do_action( 'genesis_before_while' );
    while ( have_posts() ) : the_post();

        do_action( 'genesis_before_entry' );

        printf( '<article %s>', genesis_attr( 'entry' ) );

            do_action( 'genesis_entry_header' );

            do_action( 'genesis_before_entry_content' );

            printf( '<div %s>', genesis_attr( 'entry-content' ) );
            do_action( 'genesis_entry_content' );
            echo '</div>';

            do_action( 'genesis_after_entry_content' );

            do_action( 'genesis_entry_footer' );

        echo '</article>';

        do_action( 'genesis_after_entry' );

    endwhile; //* end of one post
    do_action( 'genesis_after_endwhile' );

else : //* if no posts exist
    do_action( 'genesis_loop_else' );
endif; //* end loop

}

从创世纪到子主题functions.php。之后我的网站显示了

致命错误:无法在 /home/u282646374/public_html/wp- 中重新声明 genesis_standard_loop()(之前在 /home/u282646374/public_html/wp-content/themes/modern-studio-pro/functions.php:198 中声明)第 115 行的 content/themes/genesis/lib/structure/loops.php

我已从子主题中删除了该代码,但网站未显示。请告诉我如何才能恢复我的网站?这是我的页面链接http://andrewspalding.co.uk/

【问题讨论】:

    标签: php wordpress genesis


    【解决方案1】:

    您的问题是您在子主题的functions.php 内重新声明了函数genesis_standard_loop(),而在主创世主题中,此函数位于lib/structure/loops.php 内,子主题将覆盖父主题函数,如果它们在同一个主题中文件,如果您想修改父主题中的功能,您可能会考虑寻找 filtersactions 的想法。

    如果您必须重新声明该函数,请尝试重新创建相同的文件结构,但请记住在该特定文件中添加所有其他函数。

    【讨论】:

      猜你喜欢
      • 2015-08-07
      • 1970-01-01
      • 2013-03-25
      • 2015-06-04
      • 2014-11-02
      • 2019-04-21
      • 1970-01-01
      • 2020-06-16
      • 1970-01-01
      相关资源
      最近更新 更多