Created
March 9, 2015 14:56
-
-
Save matesnippets/747cfdebf5747905c11a to your computer and use it in GitHub Desktop.
WordPress, get custom post type slug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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