I have a WordPress website and it sends some transactional emails to the users. I create the template using HTML and I've been wondering if there's a way to add the <?php echo site_url() ?> in there so I don't have to change it manually every time I create a new website.

I have already tried using the <?php echo site_url() ?> in there, but it won't work.

Here's a sample of the code I am using

<td><a href="http://domain.com/" target="_blank">Deals</a></td>

Is there any way to achieve this?

Thank you in advance for the help, Kat

  • I am assuming that you are first preparing HTML and then sending mail using wp_mail(). If so then <?php echo site_url() ?> should work. What may go wrong: You added the php code in single(') quote
    – Manish
    Sep 18, 2013 at 19:41
  • Please add the code you've tried to your question. Also, when you say "I create the template using HTML", is your file's extension .html or .php?
    – Pat J
    Sep 18, 2013 at 19:52
  • It's actually through the standard editor WordPress provides. Instead of using the 'Visual' I am using the 'Text' to create it.
    – kat_indo
    Sep 18, 2013 at 19:57
  • The code is added with two quotes. I add the email content through the standard wordpress editor, but I am using the 'Text' view in order to add the HTML code of the email template. So, it's a code full of tables, etc.
    – kat_indo
    Sep 18, 2013 at 20:00
  • 3
    you can't use php in the post editor, create a simple shortcode to output the URL instead.
    – Milo
    Sep 18, 2013 at 20:02


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.