jcadima
9/21/2016 - 6:42 PM

Get Current Page Slug

Get Current Page Slug


<?php

http://wordpress.stackexchange.com/questions/42117/how-to-retrieve-the-slug-of-current-page

// Get the queried object and sanitize it
$current_page = sanitize_post( $GLOBALS['wp_the_query']->get_queried_object() );
// Get the page slug
$slug = $current_page->post_name;


// if wordpress page slug is make-a-reservation echo  r_cta else empty string
<?php echo ($slug == 'make-a-reservation') ? 'r_cta' : '' ;  ?>