Posted By

Farhan on 08/07/12


Tagged

page wordpress slug


Versions (?)

Get WP Page Slug


 / Published in: PHP
 

Function to get wordpress post/page slug to be used on for custom class etc

  1. // Put in Functions.php
  2.  
  3. function the_slug() {
  4. $post_data = get_post($post->ID, ARRAY_A);
  5. $slug = $post_data['post_name'];
  6. return $slug; }
  7.  
  8. // Put where you want to show in page or single etc. Use for custom class for each page
  9.  
  10. <?php echo the_slug(); ?>

Report this snippet  

You need to login to post a comment.