1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP - if URL is Homepage, then do this...

Discussion in 'PHP' started by espmartin, Oct 2, 2007.

  1. pokey

    pokey Active Member

    Messages:
    317
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #21
    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.
     
    pokey, Aug 27, 2009 IP
  2. sagive

    sagive Member

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #22
    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
     
    sagive, Feb 22, 2010 IP
  3. astrazone

    astrazone Member

    Messages:
    358
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    33
    #23
    I use this for pages its extremely accurate and never let me down :

     
    astrazone, Feb 22, 2010 IP
  4. espmartin

    espmartin Well-Known Member

    Messages:
    1,137
    Likes Received:
    46
    Best Answers:
    0
    Trophy Points:
    160
    #24
    Great info, from the initial answer, to todays ;-)
     
    espmartin, Feb 22, 2010 IP
  5. heyiambastian

    heyiambastian Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #25
    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):
     
    heyiambastian, Jul 28, 2014 IP
  6. xhtmlchamps

    xhtmlchamps Active Member

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    53
    #26
    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>';
    }
    ?>
     
    xhtmlchamps, Aug 18, 2014 IP