Created
June 19, 2014 09:35
-
-
Save GavinJaynes/a806e7be09e11c7957ec to your computer and use it in GitHub Desktop.
Wordpress has built in conditional functions such as is_page() and is_front(), but sometimes it's not enough. This function checks if the current url contains a slug and returns true or false respectively.
This file contains 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
/** | |
* This function checks if the page you're on is a certain page | |
* @param $slug the slug of the page you are checking for | |
*/ | |
function is_this_page($slug) { | |
$current_url = home_url(add_query_arg(array())); | |
if (false !== strpos($current_url, $slug)) { | |
return true; | |
} else { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment