我使用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
。之后我的网站显示
致命错误:无法重新声明genesis_standard_loop()(之前声明在/home/u282646374/public_html/wp-content/themes/hyundai -studio-pro/functions.php:198)在/home/u282646374/public_html/wp-content/themes/genesis/lib/structure/loops.php中的115行
我已经删除了从子主题,但网站不显示的代码。请告诉我怎样才能重新获得我的网站?这是我的网页链接http://andrewspalding.co.uk/
你的问题是,你正在重新声明函数genesis_standard_loop()
内functions.php
的子主题,而在主要的起源主题这个函数是在lib/structure/loops.php
子主题将覆盖父主题函数,如果他们在相同的文件内,他们在父主题,如果你想从父主题修改一个函数,你可能会考虑寻找filters
或actions
的想法。
如果你必须重新声明函数,尝试重新创建相同的文件结构,但要记住在特定的文件中添加所有其他函数