Edit home.php code to make change on main blog only?

I realize this probably sounds stupid, but I figured I’d ask.

I’m using Elegant Press’s Chameleon theme on my Multisite main site @ http://www.changeincorporated.org. I edited home.php to create static text below the slider.

However, I’d like to be able to use chameleon theme again on other sites in my multi install, but need to know if there some way I can edit home.php to make the static text only appear on my main blog, not on the subs? I’m sure there is another work around as well – perhaps by specifying in settings>reading that the homepage of my multis be something other than “latest posts”, but I’d like to know if there is a way to code it as well.

  • thoward
    • Site Builder, Child of Zeus

    I’d create a child theme first (make sure your work isn’t overwritten in future updates).

    Then update home.php to wrap the portion you only want on your main blog with something like :

    <?php

    if ($blog_id == 1) {

    //show just main blog content here

    }

    This assumes your main blog has an ID=1. And you need to doublecheck the exact syntax to get the blog id.

    Hope that helps!

    Tom

  • Ryan Neace
    • Site Builder, Child of Zeus

    Tom – thanks! Created child theme. On home.php, where do i place the code you gave me? Here’s what the relevant portion looks like currently:

    <div id="content-area">
    <?php if ( get_option('chameleon_blog_style') == 'false' ) { ?>
    <img class="aligncenter" title="1-877-5-CHANGE (1-888-524-2643)!" src="http://img171.imageshack.us/img171/3597/button1xd.png" alt="" width="640" height="83" /><br><p style="text-align: center;"><span style="color: #3366ff;"><strong>Change, Inc</strong>.</span> <span style="color: #000000;">St. Louis Counselors are available to help now!  The only St. Louis Counseling Practice with a <strong>No Waiting List Policy</strong>!</span></p>
    <p style="text-align: center;"><span style="color: #3366ff;"><strong>Happiness</strong> is possible, even if you need counseling for Anxiety or Depression.</span></p>
    <p style="text-align: center;"><span style="color: #000000;">Couples Counseling or Marriage Counseling can help you <span style="color: #3366ff;"><strong>Learn Forgiveness</strong></span> and <span style="color: #3366ff;"><strong>How to be Happy with Your Partner</strong></span>.</span></p>
    <p style="text-align: center;"><span style="color: #3366ff;">We can help you <strong>Find Freedom</strong> from drug addiction, alcoholism, pornography, or other addictions.  <strong>Lasting Sobriety and Recovery</strong> is possible!</span></p>
    <p style="text-align: center;"><span style="color: #000000;"><strong>Letting Go</strong> of guilt and shame from the past, and <strong>Learning How to Move Forward With Your Life</strong> are experienced through counseling.</span></p>
    <p style="text-align: center;"><span style="color: #3366ff;">Relationships are <strong>Restored</strong>, <strong>Revitalized</strong>, and <strong>Renewed</strong>!</span></p>
    <p style="text-align: center;"><strong><strong>Looking for counseling in St. Louis?  Speak with a <span style="color: #3366ff;">Change, Inc.</span> St. Louis Counselor today!</strong></strong></p>
    <p style="text-align: center;"> <strong>Nervous about calling?  Email us at contact@changeincorporated.org!</strong></p><br>
    <div id="from-blog">
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Homepage') ) : ?>
    <?php endif; ?>
    </div> <!-- end #from-blog -->

  • thoward
    • Site Builder, Child of Zeus

    Assuming you want to hide lines 4 through 49, try this:

    I would put this on line 4:

    <?php

    global $blog_id;

    if ($blog_id == 1) { ?>

    Rest of your static content here (lines 4 through 49).

    Then add this line:

    <?php } ?>

    I think that should work. If not, I might need to brush up on how to check for the blog_id of the current blog but the theory is sound :slight_smile:

  • PC
    • WPMU DEV Initiate

    @thoward – yw !

    I figure I should help others while I’m waiting for help on my questions too :slight_smile:

    That indeed is a good idea, and we appreciate it very much. You not only get points for helping around but those points have rewards too !

    I’m waiting for help on my questions too :slight_smile:

    And yeah, they are being looked at as we are cleaning up the ticket lots :slight_smile:

    Cheers

    PC

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.