-2

Can someone please tell me what am I doing wrong in my code? Every time I try, I receive

Parse error: syntax error, unexpected '.'

<?php if ( is_woocommerce()){ '<a href="' . home_url(); . '">Home</a>' 
        } else { '<a href="' . home_url('/shop/'); . '">My Shop</a>' 
 }?>
COS
  • 505
  • 2
  • 4
  • 22

1 Answers1

1

Here you go:

<?php 
    if (is_woocommerce())
    { 
        echo '<a href="' . home_url() . '">Home</a>';
    } 
    else 
    { 
        echo '<a href="' . home_url('/shop/') . '">My Shop</a>';
    }
?>
dazed-and-confused
  • 1,293
  • 2
  • 11
  • 19
  • So in other words I forgot the echos :) .I knew I was close. Thank you ! – COS Sep 14 '19 at 13:49
  • @CosminP Well two issues, the `echo`s but also note you have `;` after your call to `home_url()` which is no good as well. Good luck on your project. – dazed-and-confused Sep 14 '19 at 19:59