• Resolved bmc1416

    (@bmc1416)


    I’m using sub directories for my WordPress multisite, posts are controlled with single.php. How can instruct single.php to use a different header and footer file for the site in the sub directory?

    I tried using get_current_blog_id but that didn’t seem to work. For example:

    $current_blog = get_current_blog_id();
    
    if ($current_blog == 2) {
        get_template_part('header', 'blog2');
    } else {
        get_header();
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter bmc1416

    (@bmc1416)

    I was able to get away with using in_category() because I’m only using 1 category on the sub directory site:

    if (in_category('News')) {
         get_template_part('header', 'blog2');
    } else {
         get_header();
    }
    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    You can also use blog ID 🙂

    global $blog_id;
    
    if ( $blog_id == 2 ) {
        get_template_part('header', 'blog2');
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Handling single.php in Multisite’ is closed to new replies.