• Resolved issora

    (@issora)


    Hi there,

    I’m trying to include a conditional statement in the archive.php file that allows me to customize the standard Archive headers for each blog in the network. I’ve been researching this for days, and thought I’d come up with the solution with the following code:

    <?php
    $current_blog_id = $GLOBALS['blog_id'];
    
    if ($current_blog_id == 2) {
    code here;
    } 
    
    elseif ($current_blog_id == 3) {
    and here;
    } 
    
    else {
    and default here;
    }
    ?>

    However, I’m getting syntax errors thrown at me in Dreamweaver. Also, I’m not sure how to include PHP within the conditionals, as shown in the code below:

    <?php
    $current_blog_id = $GLOBALS['blog_id'];
    if ($current_blog_id == 8) {
    
    <?php /* If this is a category archive */ if (is_category('exclude=8')) { ?>
    
    <h2 class="pagetitle">Archive for the ‘<?php single_cat_title(); ?>’ Category</h2>
    
    <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
    <h2 class="pagetitle">Posts Tagged ‘<?php single_tag_title(); ?>’</h2>
    
    <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    <h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2>
    
    <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    <h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2>
    
    <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    <h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2>
    
    <?php /* If this is an author archive */ } elseif (is_author()) { ?>
    <h2 class="pagetitle">Author Archive</h2>
    
    <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
    <h2 class="pagetitle">Blog Archives</h2>
    
    <?php } ?>
    
    ;
    } 
    
    elseif ($current_blog_id == 2) {
    do this;
    } 
    
    else {
    do this;
    }
    ?>

    Can anyone help? Or point me in the direction of a thread with some info? I’ve been researching this for days, and haven’t come up with a solution yet. Thank you in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Use global $blog_id; instead.

    <?php
    global $blog_id;
    
    if ($blog_id == 2) {
    code here;
    } 
    
    elseif ($blog_id == 3) {
    and here;
    } 
    
    else {
    and default here;
    }
    ?>

    Start simple, with a basic echo and then work up ??

    Thread Starter issora

    (@issora)

    Works beautifully, thank you!! Code below for anyone interested:

    <?php
    global $blog_id;
    
    if ($blog_id == 5) {
    echo wp_list_categories('exclude=8&title_li=');
    
    } 
    
    if ($blog_id == 4) {
    echo wp_list_categories('exclude=3&title_li=');
    
    } 
    
    else {
    echo wp_list_categories('title_li=&show_option_all=');
    }
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multisite Conditional – if blog_id?’ is closed to new replies.