The in_category( $category )
conditional only returns true when the current post has the specified category assigned. If you want to determine when you are on a category archive index page, you should instead use is_category( $category )
:
if ( is_category( 'Restaurant Reviews' ) ) {
// The current page is the Restaurant Reviews
// category archive index page; do something
}
Side note: is_home()
returns true when the current page is the blog posts index, which will not always be true for the site front page. If the site uses a static front page, the blog posts index will be on a separate, static page, and is_home()
will not return true on the site front page. So, if you actually intend to query for the site front page, use is_front_page()
:
<?php
if ( is_front_page() ) {
// set up for home page ad
} elseif ( is_category( 'Restaurant Reviews' )) {
// set up for restaurant reviews ad
} else {
// set up for run of site ad
}
?>