add_action( 'init', 'wc_readd_add_to_cart_buttons' );
function wc_readd_add_to_cart_buttons() {
  //add to cart button loop
  add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );

I am adding back a button in WooCommerceand need to have a <br> before the button. How do I insert a <b> inside the above action?

2 Answers 2


You can use 'echo' (or 'print') to enclose HTML, but sometimes that gets a bit messy with complex HTML, not to mention having to escape quote/double-quote character.

So try something like this:

function myfunction() {
  // after this next, plain HTML
  <div class='myclass'><h1 align="center">This is a heading</h1></div>
  <!-- more HTML code here -->
  <?php   // back to PHP
  // .. some more PHP stuff

That allows you to put in some complex HTML (or a bunch of it) without having to use echo/print.


Not sure why you are using init and then adding the function to the WC action. The following should work:

add_action( 'woocommerce_after_shop_loop_item', 'wc_readd_add_to_cart_buttons', 10 );
if (!function_exists('wc_readd_add_to_cart_buttons')){
   function wc_readd_add_to_cart_buttons() {
    //add to cart button loop
    echo "<br />";

Not the answer you're looking for? Browse other questions tagged or ask your own question.