I am trying to retrieve the slug of the current wordpress page outside the loop. The title of the page returns with wp_title () but how can I get the slug?
<li><a href="/slug-of-current-page/"><?php wp_title("",true); ?></a></li>
|
|
|
use global variable
|
||||
|
|
You can use get_permalink() outside of the loop, that should do what you need. |
|||
|
|
|
An alternative to Arvind's solution is to use the sanitize_title function: In this specific case:
|
|||
|