2013-08-25 131 views
1

這甚至可能嗎?我的意思是,即時嘗試添加一個博客到我的網站..我已經在我的網站中的頁眉,頁腳和側邊欄佈局。我可以在我的自定義WordPress模板中使用這些模板嗎?將外部PHP文件包含到Wordpress自定義模板中

<?php 
/* 
Template Name: Blog 
*/ 
?> 
<?php include(PATH . 'http://www.mysite.com/includes/header.php'); ?> 
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 

<div <?php post_class() ?> id="post-<?php the_ID(); ?>"> 
    <h2><a href="<?php the_permalink() ?>"> 
    <?php the_title(); ?> 
    </a></h2> 
    <?php include (TEMPLATEPATH . '/inc/meta.php'); ?> 
    <div class="entry"> 
    <?php the_content(); ?> 
    </div> 
    <div class="postmetadata"> 
    <?php the_tags('Tags: ', ', ', '<br />'); ?> 
    Posted in 
    <?php the_category(', ') ?> 
    | 
    <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?> 
    </div> 
</div> 
<?php endwhile; ?> 
<div class="mypagination"> 
    <?php include (TEMPLATEPATH . '/inc/nav.php'); ?> 
</div> 
<?php else : ?> 
<h2>Not Found</h2> 
<?php endif; ?> 
<?php include(PATH . 'http://www.mysite.com/includes/sidebar.php'); ?> 
<?php include(PATH . 'http://www.mysite.com/includes/footer.php'); ?> 

我也試過..

<?php include('http://mywebsite.com/includes/header.php'); ?>

回答

0

假設你想包括在同一臺服務器作爲您正在創建的頁面上的PHP文件,嘗試包括他們的系統的.php文件路徑,這可能類似於/var/www/path/to/header.php,至少對於大多數基於Unix的服務器而言。

+0

是的,他們在同一臺服務器,,,生病嘗試.. –

+1

你的意思是這樣的? <?php include('/httpdocs/includes/header.php'); ?> –

+0

是的,這是做到這一點。 – mfabel

相關問題