Hide Elements on Specific WordPress Pages Using If , else Condition
Today we are sharing the code for hiding Elements or div on Specific WordPress Pages Using If, else Condition. Use the below codes for hiding Elements or div on WordPress home page, archive page, and for a specific category.
<?php if(is_front_page() ) { ?> <div class="joint_btn">Only for Front/home page</div> <?php } ?> <?php if(!is_front_page() ) { ?> <div class="joint_btn">all other pages exclude Front/home page</div> <?php } ?> <?php if(is_front_page() ) { ?> <div class="joint_btn">Only for Front/home page<</div> <?php } else{?> <div class="joint_btn">Only for Other pages exclude Front/home page</div> <?php } ?> <?php if(is_archive() ) { ?> <div class="banner_in">Only for archive page</div> <?php } ?> <?php if(is_archive() ) { ?> <div class="banner_in">Only for archive page</div> <?php } else{?> <div class="joint_btn">Only for Other pages exclude archive page</div> <?php } ?> <?php if( in_category( 'news' )) { ?> <div class="banner_in">Only for news category</div> <?php } ?> <?php if( in_category( 'news' )) { ?> <div class="banner_in">Only for news category</div> <?php } else{?> <div class="joint_btn">Only for Other category exclude news category</div> <?php } ?>