Skip to content

Instantly share code, notes, and snippets.

@matesnippets
Created March 9, 2015 14:56
Show Gist options
  • Select an option

  • Save matesnippets/747cfdebf5747905c11a to your computer and use it in GitHub Desktop.

Select an option

Save matesnippets/747cfdebf5747905c11a to your computer and use it in GitHub Desktop.
WordPress, get custom post type slug
/**
* Gets a slug of a custom posty
* @param string $post_type The post type wanted
* @return string Slug for the post type
*/
function slugger($post_type)
{
if ($post_type) {
$post_type_data = get_post_type_object($post_type);
$post_type_slug = $post_type_data->rewrite['slug'];
return $post_type_slug;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment