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

The entire functions.php file in my child theme currently is:

<?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 );
?>

I need to add a snippet to change the footer. I got this snippet from WordPress support, but every place I insert it I get a syntax error. I’ve inserted it multiple ways, properly nested in tags, but my site always breaks. Could a kind person please show me how the entire functions.php files should look, after I insert this snippet?

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
}
?>

Related posts

1 comment

  1. If you want PHP code to execute, it will need to be after a PHP open tag. If it’s positioned after a PHP close tag, it will be displayed as plain text on your website, which you do not want.

Comments are closed.