Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
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.