Custom PHP code won't show up in Wordpress theme?
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).
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' ); ?>
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