Search code examples
wordpresspermalinks

the_permalink() returning only slug


On my wordpress site, the_permalink() returns only the slug, and not the full URL. So, for example, for the page:

https://www.example.com/hello-world

the_permalink would return /hello-world/.

This works most of the time as the_permalink() is used mostly for links within the site, but it causes problems when I use them for share links.

From docs and other examples, I think the_permalink() is supposed to return the full URL. Why is it returning something different for me? I don't think anyone has added a filter for the function.


Solution

  • It turns out the reason is that I have the "Relative URL" plugin installed, which calls wp_make_link_relative() to make everything relative! That explains everything.