/ Published in: PHP

Function to get wordpress post/page slug to be used on for custom class etc
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// 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 <?php echo the_slug(); ?>
Comments
