Support » Fixing WordPress » How To Call To A Diffrent Header Depending On The URL

  • Resolved Jessica

    (@thejessicapage)


    I would like to call to a different header depending on the url. I have tried this code:

    $url = $_SERVER["REQUEST_URI"];
    if (strpos($url, "/occupational/wohl/") === 0) {
     include "/wp-content/themes/wslh/header-wohl.php";
    } else {
     include "/wp-content/themes/wslh/header.php";
    }

    This does not appear to work. I placed it in the page.php and the index.php but for some reason I can not get it to function.

    Any thoughts on how this might work?
    Thank you in advance.

Viewing 1 replies (of 1 total)
  • Jessica

    (@thejessicapage)

    Well, I was able to figure out how to do this, and as no one has replied, I figured I would place the answer in case it will help someone in the future.

    I placed the following code in my page.php:

    // Call to appropriate header
    $url = $_SERVER["REQUEST_URI"];
    if (strpos($url, "/url-here/page-name-here/") === 0) {
     get_header(newname);
    } else {
     get_header();
    }

    Note: if you have a header.php and then a header-newname.php, you can call to it like this:

    get_header(wohl);

Viewing 1 replies (of 1 total)
  • The topic ‘How To Call To A Diffrent Header Depending On The URL’ is closed to new replies.