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;>
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.