Assuming you’re doing this from inside the Loop, you can get it this way:
global $post;
$page_slug = $post->post_name;
Then just use echo $page_slug;
in the location(s) you which to have it displayed.
For outside the loop, you will need to use different code:
$the_page = sanitize_post( $GLOBALS['wp_the_query']->get_queried_object() );
$slug = $the_page->post_name;
Related Posts:
- How to set post slug when using wp_insert_post();?
- Can I have two child pages of different parents with the same name?
- Creating a template using a specific slug name, for a page with a parent page
- Slug is redirecting to 404
- Using page slug in array
- List child pages by slug not ID?
- Create a page that’s to not be indexed or accessible via slug
- Attachment pages stealing page slugs
- Is it possible to restrict access to specific pages in the admin area based on the page slug?
- Is it possible to change slugs’ default behaviour?
- Page Slug Won’t Change – Can’t Edit Archive Page With Slug or Reassign Slug
- Can’t find the page that is using a slug
- How do I locate a third party page represented as a slug in my WordPress website?
- Cannot use old slug – it just 301s to site home page
- Using Page/Post Slug In Link / URL
- Show more than 20 items in pages or posts edit dashboard
- How to display last 3 posts (recent posts) in a static page?
- Editing Complex Pages in Visual Mode
- Multiple areas of dynamic content in a page
- How to create virtual pages with information from user meta profile fields?
- Private pages that work when you are not logged into WP admin
- Using same slug name for a page and category
- How to limit page pagination
- Add custom text at bottom of every page?
- Remove specific page/post from feed
- Want Page Title to show on menu, but not on page
- Personal page for every user (not just authors)
- Create ghost page
- List pages by custom field?
- Send mail from page using wp_mail
- Edit page’s “Restore the backup” link does nothing
- Load specific page template based on URI
- Show preview posts and pages to clients
- I can’t edit my homepage – the page editor is just blank [closed]
- Page redirects to archive
- Pages Column Sorting WordPress Version 3.0.3
- Adding Page URL to the Pages Admin Table
- More Fields Required For Password protect page
- page-name.php doesn’t execute on custom template
- Add categories and posts to page hierarchy
- How to use is_admin in page content?
- Adding a Calculator to a WordPress Page
- List all posts with the parent or grandparent of a page with a specified ID
- Why isn’t WordPress respecting my HTML?
- From a developer’s point of view what are the differences between pages and posts? [closed]
- Edit page shown after login in WordPress?
- invalid argument in foreach when trying to list custom post types in archive.php
- Page titles for internal classification of landing pages
- Function to incorporate an option in each Page
- Displaying direct children of other pages on homepage
- How to bypass 404 for certain pages/posts?
- Displaying Current Page Number Conditionally
- Multiple Loops That Pull Pages (Child/Grandchild) While Styling the First Entry
- How do i pick the pages in 20-11 header?
- page template – undefined structure in source code
- How to show page title with capitalization only as I typed in?
- Create custom page to author.php
- Make Audio Element Persistent Across Pages
- My site does not load but downloads a file (wordpress)
- Show children connected to parent pages
- How to get an array of pages ID by some page’s slug and all its children pages in get_posts() function?
- Restrict specific private page to a specific user
- How to remove a page in its entirety
- Set different heights per screen size with inline styles CSS into the ‘Text’ section of a Page
- Editing Pages Icons Are Not Showing Up – Why is this happening?
- How to add custom php file to right sidebar?
- Why my home page doesnt work?
- Mailchimp RSS feed work with single wordpress page?
- Cannot pull WYSIWYG content
- How can I change the background color of a contact box? [closed]
- Creating content using wp-admin pages
- change page status with code
- Press This for Page
- Supress listing of virtual pages
- How to limit the pages shown in the page manager to those created by the logged in user?
- Is it better to set social media sharer in entry-footer.php or comments.php in WordPress blog?
- Get All Pages as strings in array
- Attach link to pages accoding to tags
- Search Page: activate html code if the tag is on the page
- Issue with page not erasing
- My page won’t publish
- Pages redirecting to homepage
- Echo page path suffix only – not the title, path or permalink
- Why does the default Insert/edit link function in Visual mode in posts or pages produce full urls?
- Custom admin menu for a selection of pages
- how to print the content of pages inside the front end area
- How do I make just one of my pages a Blog Page?
- Standard way of creating profile pages with custom content for each user?
- How to show parent pages on a specific page if user is logged in?
- Retrieve page content and pass to PHP?
- How to make in post Parent page children page list nummbered
- Advanced Multi Tier Navigation across columns
- How To Display Pages Based On Subscriber Signup Date
- How to preview a page instead of a category?
- Display list of posts with x tag within a page?
- Custom wp_list_pages() function
- Split Page Links
- Ask for template when adding a new page
- How to view front-end of WordPress website, using Atom?
- Custom template is not showing up in templates dropdown list after re-naming it