Thanks for this information guys, really has helped me. I know this topic is probably a wee bit old, but though gratitude is always important.
thanks a lot young coder i needed that to activate some banners on my wordpress blog but couldnt make it apear only in my home page.. you trully helped, Cheers sagive
hey! iknow this topic is really old but im trying to do something similar in my wordpress page the idea is show some div if i am on one url or another div if i am in a different page but it doesnt work, the page doesnt crush but goes to the else stament always here is the code i hope someone cant help!! <?php $homepage = "www.articoaudiovisual.com/baby/blog/"; $currentpage = $_SERVER['REQUEST_URI']; if($homepage==$currentpage) { ?> <div class="blog-filter-container"> <div class="row"> <div class="col-md-12 blog-filer"> <ul> <li class="active"> <a href="<?php if( get_option( 'show_on_front' ) == 'page' ) echo get_permalink( get_option('page_for_posts' ) ); else echo bloginfo('url'); ?>"> <?php _e('All','oneengine') ?> </a> </li> <?php $categories = get_categories( array('hide_empty' => 0) ); foreach ($categories as $category) { ?> <li> <a href="<?php echo get_category_link( $category );?>"> <?php echo $category->name ?> </a> </li> <?php } ?> </ul> </div> </div> </div> <?php } else{ echo 'Fail: ', $host, PHP_EOL;?> <div class="blog-filter-container"> <div class="row"> <div class="col-md-12 blog-filer"> <ul> <?php $tags = get_tags( array('hide_empty' => 0) ); foreach ($tags as $tag) { ?> <li> <a href="<?php echo get_tag_link( $tag );?>"> <?php echo $tag->name ?> </a> </li> <?php } ?> </ul> </div> </div> </div> <?php } ?> Code (markup):
Hi, You can restrict some content or what ever to home page only.You need to do follow below code. <?php $currentpage = $_SERVER['REQUEST_URI']; if($currentpage=="/" || $currentpage=="/index.php" || $currentpage=="" ) { echo '<li>Home</li>'; } ?>