/ Published in: PHP

This function returns the slug fot the given post...
Expand |
Embed | Plain Text
// @ WordPress // Returns the post slug // Make sure to use this inside the loop //---------------------------------------------------------- function the_slug($postID="") { global $post; $postID = ( $postID != "" ) ? $postID : $post->ID; $post_data = get_post($postID, ARRAY_A); $slug = $post_data['post_name']; return $slug; } //---------------------------------------------------------- // to get var: <?php $slug = the_slug(); ?> or <?php $slug = the_slug('23'); ?>
You need to login to post a comment.