Reputation: 359
I have a wordpress website with a banner link showing as below:
<a href="<?php echo site_url(); ?>" >Banner</a>
And this will return a result as: http://example.com
What I want is to let the site_url have a trailing slash, so the address would look like http://example.com/
So my question, is it okay to concatenate the site_url() with a trailing slash like this?
<a href="<?php echo site_url() . '/'; ?>" >Banner</a>
Upvotes: 0
Views: 1013
Reputation: 436
The accepted answer works, but if you want a full WP solution, use trailingslashit()
:
$url = trailingslashit( site_url() );
Upvotes: 1
Reputation: 38552
Yes, what you are did is Ok. But I have a little different solution weather it contains trailing slash or not just add it like this.
$url = site_url();
echo rtrim($url ,"/").'/';
Upvotes: 1