PHP – WordPress – Get Page Slug

The given PHP example is a function to get wordpress post/page slug to be used on for custom class

Code Example:
// Put in Functions.php
function the_slug(){
	$post_data = get_post($post->ID, ARRAY_A);
	$slug = $post_data['post_name'];
	return $slug;
// Put where you want to show in page or single etc. Use for custom class for each page
echo the_slug();

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

Leave a Comment

Your email address will not be published. Required fields are marked *