I want to echo a PHP function with some string literal HTML.
This is how I thought it was done:
echo '<a href="' + $prevpost->url() + '" class="postnav left nextpost"></a>';
...but that returns nothing. I've tried small variations on where the quotes are etc. but I'm worried I'm barking up the wrong tree and I can't really find what I need from searching.
Note: echo $prevpost->url(); does return the URL I am trying to link to, before anybody asks if that works.
The concatenation operator in PHP is . and not +
Change it to below, in php . (dot) is used as a concatenation operation in php,
echo '<a href="' . $prevpost->url() . '" class="postnav left nextpost"></a>';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With