在WordPress子主题的functions.php文件中插入此片段的位置


Where to insert this snippet in functions.php file of WordPress child theme

我的子主题中的整个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( 'parent-style', get_template_directory_uri() . '/style-rtl.css' );
   }
 ?>
<?php
  // Display 6 products per page. Goes in functions.php
  add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 6;' ), 20 );
?>

我需要添加一个片段来更改页脚。我从WordPress支持中得到了这个片段,但每次插入它的地方都会出现语法错误。我已经用多种方式插入了它,正确地嵌套在标签中,但我的网站总是崩溃。请好心人告诉我,在我插入这个片段后,整个functions.php文件应该是什么样子?

add_action( 'init', 'custom_remove_footer_credit', 10 );
function custom_remove_footer_credit () {
  remove_action( 'storefront_footer', 'storefront_credit', 20 );
  add_action( 'storefront_footer', 'custom_storefront_credit', 20 );
} 
function custom_storefront_credit() {
?>
  <div class="site-info">
     &copy; <?php echo get_bloginfo( 'name' ) . ' ' . get_the_date( 'Y' ); ?>
  </div><!-- .site-info -->
<?php
}
?>

如果您想执行PHP代码,它需要在PHP打开标记之后。如果它位于PHP关闭标记之后,它将在您的网站上显示为纯文本,这是您不希望的。