mattmikulla
Member
Posted 2 years ago #
I have a static front home page. My blog is located at mysite.com/blog/.
Is there a conditional that says the following:
If on /blog/
Then show this
Else
Something else
End if
I basically have a different navigation I want to show when only on the blog.
This will check for /blog/ anywhere in URL, but chances are you will only have /blog/ in URL when at the blog.
/ defines start and end of the pattern to match so the / in blog are escaped \/
<?php
if(preg_match("/\/blog\//",$_SERVER['REQUEST_URI'])){
//if /blog/ is anywhere in the URL..
}else{
//if /blog/ is not in URL
}
?>
Far better to use WP conditionals:
<?php if( is_home() ) :?>
[ show this]
<?php else:?>
[ something else]
<?php endif;>
mattmikulla
Member
Posted 2 years ago #
Esmi, I don't think that will work since my home page is not my blog but static content for the front of the site.