WordPress: How to get the Slug of the page
When working with WordPress templates, we frequently find ourselves trying to get certain information about a page. It bothers me how “non” object orientated page information is in WordPress, but those are the hurdles you need to get over as a web developer.
Today I wanted to get the “Slug” (or the last part of a Permalink for a page).
This page has the following slug:
wordpress-how-to-get-the-slug-of-the-page
If you want to get that value for whatever page you are on:
<? $postObject = $wp_query->get_queried_object(); ?> The Slug of this page is: <?= $postObject->post_name ?>
No comments yet.
Leave a comment
Please share, it makes me happy:
Subscribe to Email Alerts
Make a Donation
Popular Posts
Follow Me
Recent Posts
Archives
Tags
3g Actionscript Adobe AJAX Android Apple Apple TV AT&T Blog Browsers Chrome CSS css3 Facebook Firefox Flash Google help HTML HTML5 ie6 IE8 Internet Explorer iOS iOS 4 iOS 5 iPad iPhone iPhone 4 iPhone 4S iTunes Javascript jQuery Microsoft PHP Safari SEO Steve Jobs Tutorial Twitter Verizon Video web developer WordPress Youtube
Blogroll
- 456 Berea St
- ActionScript 3 Design Patterns
- adactio – home of Jeremy Keith
- ajaxian
- Boxes and Arrows
- Chris Brogan
- CSS Globe
- InsideRIA
- Jarrod Michael Studios
- Johan Brook: Designer and Developer
- Mad Vertices
- NETTUTS
- Portsmouth Community Calendar
- Roomware Blog
- Signal vs. Noise
- Six Revisions
- Snook
- Style Grind
- Tiago’s Weblog
- Viget Extend
- Vitamin
- Whats the latest
- Woork
- zupko.info
