2010-10-02 90 views
0

这让我绝对难住!自定义PHP代码不会显示在Wordpress主题中?

我有一小段PHP代码,<?php include('/includes/stuff.php'); ?>。它所做的只是输出图像。

如果我把这个放在WP主题的header.php或index.php文件中,它永远不会显示出来。 下面是实际的代码在我的主题index.php文件:

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

但是,当它实际运行,它看起来像:

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

它只是忽略我的代码完全。没有错误,没有任何东西。

我唯一能得到它的工作是如果我将它包含在已包含的文件中。例如,在header.php中有一个用于features.php的包含。如果我把它包括在内,它就可以正常工作。但我不想在那里,我需要它在index.php。

在wordpress中是否有某种配置需要知道所有包含什么?我确认我的文件正在被修改(在FTP上)。

编辑

我只是想get_template_part(),作为对WordPress的抄本描述,但无济于事。这里是我试过的片段:

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

贾里德

+0

你_very_确保路径是正确的? '/ includes/stuff.php'意味着你有一个名为'includes'的_root level_目录,而不是你的项目中的某个地方。另一方面,我从来没有使用Wordpress,可能是一个缓存问题。 – Wrikken 2010-10-02 15:40:24

回答

相关问题