Display custom header depending on the directory of the site (multisite) (2 posts)

  1. cokeyblokey
    Posted 3 years ago #

    I'm working on a multi-language site with a multisite install of WP. The site is English and German, with the English site in the root, and the German site in a directory within the root (www.mysite.com/de). I want to use different headers for each site.

    I know how to achieve different headers on a per page basis

    if (is_page('contact')){
    elseif (is_page('gallery')){
    else {

    but how can I achieve this based on the folder? Does WP have a function for this?

    if folder is /de load de-header.php
    else load header.php

    Any help on how to achieve this with php would be greatly appreciated.

  2. cokeyblokey
    Posted 3 years ago #

    OK, found some suitable code elsewhere, so to answer my own question:

    $uri_segments = explode( '/', $_SERVER['REQUEST_URI'] );
    if ( in_array('de', $uri_segments) ) { get_header('german');
    else{ get_header();

    That works perfectly for me, but I'd be interested to hear if there's a better way to do it?

Topic Closed

This topic has been closed to new replies.

About this Topic