WordPress: How to get the Slug of the page

Tuesday, February 9th, 2010 | Business, Tutorials | by

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:


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 ?>

Related Posts

Tags: , ,

No comments yet.

Leave a comment


Please share, it makes me happy:

Subscribe to Email Alerts

Follow Me

Follow seangw on twitter



prestashop theme

virtuemart template