WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] php include outside header file (7 posts)

  1. chowpay
    Member
    Posted 6 years ago #

    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:

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

    http://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.

  2. Dion Hulse
    WordPress Dev
    Posted 6 years ago #

    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..

  3. chowpay
    Member
    Posted 6 years ago #

    ok i will give this a shot

  4. chowpay
    Member
    Posted 6 years ago #

    actually that wouldnt work because now it works for WP but it doesnt work for http://www.website.com because now its looking for http://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

  5. chowpay
    Member
    Posted 6 years ago #

    bump

  6. rob0210
    Member
    Posted 6 years ago #

    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!

  7. chowpay
    Member
    Posted 6 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic