1

这甚至可能吗?我的意思是,我试图在我的网站中添加一个博客。我的网站中已经有了页眉、页脚和侧边栏布局。我可以在我的自定义 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'); ?>

4

1 回答 1

0

/var/www/path/to/header.php假设您要包含的 php 文件与您正在创建的页面位于同一台服务器上,请尝试通过它们的系统路径包含 .php 文件,至少对于大多数基于 unix 的服务器来说,这可能类似于。

于 2013-08-25T18:58:54.013 回答