Created
January 15, 2016 21:14
-
-
Save jserrao/198149dfee62c16eb84c to your computer and use it in GitHub Desktop.
WordPress - Get Slug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Something important to remember about WordPress is that it's functions act differently depending on your template | |
// This might be the single most annoying thing about WP | |
// You can get information out of WP but it's very situational | |
// 1- get the slug is with get_queried_object (on a page) | |
$slug = get_queried_object()->post_name; | |
// 2- Checkout the permalink, another way to do this (on a page) | |
$slug = basename(get_permalink()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment