tags:

views:

44

answers:

2

This has me absolute stumped!

I have a small snippet of PHP code, <?php include('/includes/stuff.php'); ?>. All it does is output an image.

If I put this in the WP themes header.php or index.php files, it will never show up. Here is the actual code in my the themes index.php file:

<img src="<?php bloginfo('stylesheet_directory');?>/images/content-top.gif" alt="content top" class="content-wrap" />
         <?php include('/includes/stuff.php'); ?>  TEST TEST TEST //this is the custom code
        <div id="content">

But when it actually runs, it looks like:

<img src="http://www.bavarianblue.com/wp-content/themes/Polished/images/content-top.gif" alt="content top" class="content-wrap" /> 
    <div id="content"> 

It just ignores my code entirely. No errors, no nothing.

The only time I could get it to work is if I included it in an already included file. For instance, in header.php there is an include for a features.php. If I included it there, it worked fine. But I don't want it there, I need it in index.php.

Is there some kind of configuration in wordpress where is needs to know all includes or something? I confirmed that my files are being modified (on the FTP).

EDIT

I just tried get_template_part(), as described on the wordpress codex, to no avail. Here is the snippet I tried:

<?php get_template_part( 'includes/stuff' ); ?>

Jared

A: 

Try the full path to stuff.php. Also, your host might be running php in safe mode, so check your file permissions.

Another way to include php functions in WordPress is via the functions.php file in your theme: http://codex.wordpress.org/Theme_Development#Functions_File

songdogtech
A: 

I have no idea why, but changing the index.php files does nothing for the theme. I have to change include/default.php - both index.php and default.php have similar layouts (elements of the same name). In fact, if I delete index.php from the theme entirely, it has no effect on the website. Whoever coded the theme was a bit lazy...

Jared