• Hello

    I’m building my site on a subdomain.

    I am using a php include to reference a html file which is in the root folder, like this:

    <?php include ABSPATH.'myfile.html';?>

    I’ve also tried this:

    <?php include ‘myfile.html’;?>

    If I am using default permalinks, it works great

    If I choose any of the other permalinks settings, it only works on whichever page I have set to be the static front page. All other pages just leave a space where the included file should be.

    Can anyone please help me?

    Cheers x

Viewing 7 replies - 1 through 7 (of 7 total)
  • Dion

    (@diondesigns)

    If your goal is to output a static HTML file, then try this instead:

    <?php readfile(ABSPATH .'myfile.html'); ?>

    An error will be generated if the file doesn’t exist.

    Thread Starter wambamboo

    (@wambamboo)

    Thanks – tried it but it made no difference. No error, still just a blank space, and still worked on static home page.

    Dion

    (@diondesigns)

    Where are you adding this code? If in one of the theme files, such as page.php or index.php, make sure it is in every theme file that you might use for a homepage.

    You can make sure it only displays on the front page by using the is_front_page() check.

    Thread Starter wambamboo

    (@wambamboo)

    Hi – I’m using it in a partial template of the footer. So would expect it to show up on every page. It’s setting the permalinks that breaks it, but I can’t work out why.

    Thread Starter wambamboo

    (@wambamboo)

    Update – it is actually reading the html file, as I put some dummy text in there. Just not outputting the canvas.

    Thread Starter wambamboo

    (@wambamboo)

    I’ve also tried it with other themes – 2013, 2014, and the problem remains the same.

    BUT I tried embedding as an iframe instead and it seems to be working!

    Is there any reason not to use an iframe?

    Thread Starter wambamboo

    (@wambamboo)

    Solved. path to js file wasn’t right. Check your filepaths, kids!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘permalinks causing issues with php includes’ is closed to new replies.