Skip to main content
Explained my answer better.
Source Link
Matthew Boynes
  • 7.1k
  • 2
  • 23
  • 36

YouGiven the code example, it looks like what you really need is a link. In that case, you can use get_permalink(), which can be used outside of the loop, that. That should do what you need more reliably than using the post slug.

You can use get_permalink() outside of the loop, that should do what you need.

Given the code example, it looks like what you really need is a link. In that case, you can use get_permalink(), which can be used outside of the loop. That should do what you need more reliably than using the post slug.

Source Link
Matthew Boynes
  • 7.1k
  • 2
  • 23
  • 36

You can use get_permalink() outside of the loop, that should do what you need.