Which WP function do I need to display certain things includes on the main page only?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Si
    Such Fun!
    • Feb 2008
    • 13900

    #1

    Which WP function do I need to display certain things includes on the main page only?

    I've got a few things I have added into my site. That are using <?php include> tags.

    One is in sidebar.php / one is in footer.php etc.

    Problem is I only want to display these includes on the main page.

    What's the best way to do it?
  • Jdoughs
    Confirmed User
    • Mar 2004
    • 5794

    #2
    Originally posted by Si
    I've got a few things I have added into my site. That are using <?php include> tags.

    One is in sidebar.php / one is in footer.php etc.

    Problem is I only want to display these includes on the main page.

    What's the best way to do it?

    PHP Code:
    <?php
    wp_reset_query();
    if (is_home() ) {
    echo 'Put All Your Shit In Here';
    } 
    ?>
    Alternatively, is something like this.

    PHP Code:
            <?php if (is_home()) { ?>
            <h1><a href="<?php echo get_settings('home'); ?>/"><img src="<?php bloginfo('template_url'); ?>/images/logo.png" alt="<?php bloginfo('name'); ?>" /></a></h1>
            <?php } else { ?>
            <h4><a href="<?php echo get_settings('home'); ?>/"><img src="<?php bloginfo('template_url'); ?>/images/logo.png" alt="<?php bloginfo('name'); ?>" /></a></h4>
            <?php } ?>

    Here's a good way to pick out certain categories (for picking out and advertising only gay sites on gay/tranny as per this example)

    PHP Code:
    <?php
    if (is_home() ) {
        include(TEMPLATEPATH."/banner.php");
    } else if ( is_category( 'gay-dicks' ) || post_is_in_descendant_category( 25 ) ) {
        include(TEMPLATEPATH."/bangay.php");
    } else if ( is_category( 'tranny' ) || post_is_in_descendant_category( 66 ) ) {
        include(TEMPLATEPATH."/bantranny.php");
    } else {
        include(TEMPLATEPATH."/banner.php");
    }
    ?>
    LinkSpun - Premier Adult Link Trading Community - ICQ - 464/\281/\250
    Be Seen By New Webmasters/Affiliates * Target out webmasters/affiliates based on niches your sites are for less than $20 a month.
    AmeriNOC - Proudly hosted @ AmeriNOC!

    Comment

    • fris
      Too lazy to set a custom title
      • Aug 2002
      • 55689

      #3
      what jdoughs said
      Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

      Comment

      • Si
        Such Fun!
        • Feb 2008
        • 13900

        #4
        Thanks J

        I remember you posting something about it before, but couldn't find the thread.

        This should work perfectly

        Comment

        • fris
          Too lazy to set a custom title
          • Aug 2002
          • 55689

          #5
          what is it you wanna only display on home?
          Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

          Comment

          • Si
            Such Fun!
            • Feb 2008
            • 13900

            #6
            Originally posted by fris
            what is it you wanna only display on home?
            2 php includes.

            Going to try it out in a second. Will report back with my result

            Comment

            • BSleazy
              Confirmed User
              • Aug 2002
              • 6721

              #7
              Have any of you guys seen a plugin that will let you put links only in certain categories? I looked real quick the other day but didn't see anything.
              icq 156131086

              Comment

              • Jdoughs
                Confirmed User
                • Mar 2004
                • 5794

                #8
                Originally posted by BCyber
                Have any of you guys seen a plugin that will let you put links only in certain categories? I looked real quick the other day but didn't see anything.
                There probably is a few plugin solutions that do it now but I've always used my category and tag descriptions to show unique content/links on my cat/tag pages.

                PHP Code:
                <?php $category = get_the_category();
                echo $category[0]->category_description; ?>
                You can put full html in the description fields, you can basically build full pages in there and pull them if you wanted to.
                LinkSpun - Premier Adult Link Trading Community - ICQ - 464/\281/\250
                Be Seen By New Webmasters/Affiliates * Target out webmasters/affiliates based on niches your sites are for less than $20 a month.
                AmeriNOC - Proudly hosted @ AmeriNOC!

                Comment

                • Si
                  Such Fun!
                  • Feb 2008
                  • 13900

                  #9
                  Ok it definately works. but wouldn't work with a php include unless I done it wrong.

                  Here is what i tried below:

                  <?php
                  wp_reset_query();
                  if (is_home() ) {
                  echo '<?php include "/include.html"; ?>';
                  }
                  ?>

                  Unless I have to put the full file location in there. will try that now.

                  Comment

                  • VladS
                    Available for Coding Work
                    • Jun 2008
                    • 1459

                    #10
                    Code:
                    <?php
                    wp_reset_query();
                    if (is_home() ) {
                    include "/include.html";
                    }
                    ?>
                    <developer> MechBunny / KVS / PHP / MySQL / HTML5 / CSS3 / jQuery
                    Email: vlad [at] dangerouscoding.com
                    Telegram: @dangerouscoding

                    Comment

                    • fris
                      Too lazy to set a custom title
                      • Aug 2002
                      • 55689

                      #11
                      Originally posted by Si
                      Ok it definately works. but wouldn't work with a php include unless I done it wrong.

                      Here is what i tried below:

                      <?php
                      wp_reset_query();
                      if (is_home() ) {
                      echo '<?php include "/include.html"; ?>';
                      }
                      ?>

                      Unless I have to put the full file location in there. will try that now.
                      Code:
                      <?php if ( is_home() ) : ?>
                      <?php include (TEMPLATEPATH . '/include.html'); ?>
                      <?php endif ; ?>
                      Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                      Comment

                      Working...