Try this:
$post = get_post($post_id);
$slug = $post->post_name;
Related Posts:
- how to get page id of a page using page slug
- Can we have a php “page” without a WordPress “page”?
- Put a link to a category round a hard coded A HREF
- Get ID of child from child slug, while knowing parent ID
- Get posts with at least one category in common with current post?
- Rename “Portfolio” slug?
- How do I attach a php file to an arbitrary slug and still have access to the wp-core functions?
- How to query for pages/post depending on slug?
- WordPress custom slug (endpoint) and compare all links
- Global variable $post returning incorrect object
- How do you use WP slugs for PDF files / media?
- WordPress plugin for nicer looking slugs? Have multiple pages named the same but they get different slugs
- What is an equivalent of single_cat_title for getting the slug of the category?
- What query string parameter is available for index.php, that works for both pages and blog articles?
- php script to change slug in post automatically
- List taxonomy term slugs within shortcode (do_shortcode)
- page-slug.php not working but only for specific slug
- Remove slugs from custom posts type
- Allow two posts (from different categories) to have the same slug
- Test the existence of a page/article by its URL, taking in consideration the URL rewriting by filters
- Get nice name of category from slug (remove dashes of category)
- Custom PHP form needs refresh to load page correctly
- Slug duplicates once clicking on link
- Rewrite rule not working, but only when parameter is text
- Hide a specific category title from displaying on site
- Exclude a category slug on pagination
- How can I output the slug of a comment author?
- WordPress using get_term to retreive slug not working as expected
- Weird slug in archives permalink
- php string inside shortcode does not work
- get_category only returning details for ‘uncategorized’
- How to disable page create for custom post type, but allow a page with the post types slug to be created?
- Remove /Page/ from slug when we’re visiting 2nd and other inner pages of the blog page
- Create a custom plugin with dynamic child pages listing database records
- Custom plugin with dynamic child pages listing database records
- meta box not display data input in the textarea
- Clickable image link sends people to wrong URL
- wpdb prepare insert table doesn’t work
- Should I use WordPress to skin a database website?
- php include not working in custom page
- How to modify the default feed via a function
- How do I display offsite database info on my wordpress site?
- Styling the second sidebar
- first instantiated SimplePie object cosumes 5mb?
- Adding a line of text to php code
- If ‘editor’ is empty, then
- Different Subdomain changes page content
- Theme not calling Jquery properly
- customize wordpress database error page
- Removing the comment function within wordpress
- Creating Database Table vs. Adding MetaData to Post & User
- Post’s ID pattern?
- Countdown to date function?
- Include text in echoed hyperlink
- How to put a form with php code into a variable or shortcode?
- Utilize Function in Child Theme / Template File
- Add class to DIV depending on page loaded
- Need oop for wordpress theme? [duplicate]
- Display Youtube Time Automate from Key
- Content filter won’t work
- How to retrive the text : No movie by this actor
- Make a database query using WordPress
- Is the 404 page automatically displayed if a loop returns nothing?
- update_post_meta only updating on last loop of foreach
- How to have different header.php based on the user logged in?
- How do I remove a category from a wordpress loop>
- How can i count the post added in relationship field, theme display
- Link blogname and blogdescription to the Options Framework
- Liking a facebook page from wordpress website?
- Isotope Drop Down Categories Filter Function
- First Byte Time (back-end processing)
- How do I define a lookup table that will work across all PHP elements of the template?
- How to keep track of when a vote is cast?
- trouble with page_id & highlighting current page
- Convert the_permalink() function output into string
- Making my first wordpress template
- How to use array in function to get only value I want
- Apply class to every third list item? [duplicate]
- Only show image from custom field when present
- Cinema site, retrive the movies that actor play in
- How to include custom code on a page that’s set to act as homepage?
- retain querystring values when savincustom options in admin
- PHP if statement works in template files, but not header
- How Can I Edit the Registration Code?
- Error while setting role
- Editing a PHP file to include a small text piece on every page
- Get categories names as an array to use it in theme settings
- Should i use the wordpress Options table or to create database table..?
- variable value disappears in a second loop
- Force Users To Relogin
- unknown issue in ‘header.php’ preventing theme from displaying fully
- Hide a div to subscribers(user role) in one page (is_page)
- Security updates to 3.3.2
- Where is this function’s callback getting its arguments from?
- How can I use a sliced image As banner? [closed]
- persist a variable set in header.php all the way down to footer.php
- Echo title attribute php
- Can a page contain php code?
- Last class on last headline?
- Unable to Find Space in Custom Function