• Resolved chowpay

    (@chowpay)


    Having a bit of trouble with this…

    So in my theme I want to integrate this site into an existing site. therefore using the main site’s header on my blog page . here is the structure

    website.com/blog/ <– the wp install
    website.com/header2.php <– the location of the header file i want to use , its 1 directory up from the blog

    I’ve tried adding this <?php include(‘../header2.php’);?>
    into website.com\blog\wp-content\themes\MyCustomTheme\header.php

    It DOES indeed include the file but ALL the images in that header2.php file do not work. Its trying to pull the images from:

    https://www.website.com/blog/images/myimage.gif
    it SHOULD be pulling it from

    https://www.website.com/images/myimage.gif

    I tried searching and couldn’t find a solution and I dont want to resort to iframing it if I dont have to.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Dion Hulse

    (@dd32)

    Meta Developer

    The simplest way is to modify the header to reference images absolutely.

    So instead of:
    <img src="images/myimage.gif" />
    You’d use:
    <img src="/images/myimage.gif" />

    That way it knows that its got to search for the file from the base of the HTTP site rather than from the current folder..

    Thread Starter chowpay

    (@chowpay)

    ok i will give this a shot

    Thread Starter chowpay

    (@chowpay)

    actually that wouldnt work because now it works for WP but it doesnt work for https://www.website.com because now its looking for https://www.website.com//images/myimage.gif

    There’s no way to properly include the file? some way to exclude WP from marking up the links?

    thanks

    Thread Starter chowpay

    (@chowpay)

    bump

    It may be easier if you swap the process around. Copy all the info on your header2.php and save it in the wordpress header.php file. then let wordpress do its thing!

    Thread Starter chowpay

    (@chowpay)

    thanks man,

    I think I figured it out, since the site is not all wordpress I had to hack around a little to get it to work But I hard hard linked the header. Not the most eloquent way to do things but It’ll work for now. Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘php include outside header file’ is closed to new replies.