0

简而言之,按照教程,我还没有进入“主要内容”的部分,所以像往常一样,我跳到前面并将主要内容放在侧边栏中。所以在我的“php get_sidebar()”中,我有我的主要内容和我的旁白。尽管它不是理想的格式,但我的页面看起来还不错。博客正在显示,一切都很好。请注意,我的“php the_excerpt()”在我的主要内容中,但一切都很好。然后我们到了他说要创建一个 home.php 页面并将我的主要内容放在那里的部分,它由 php get_header 和 php get_sidebar 接壤,就像它应该的那样。我认为很容易将我的主要内容从侧边栏剪切到 home.php 中(基本上是将 index.php 中的所有内容复制到 home。

<?php get_header(); ?>

<section>
    THIS IS MY TRUNCATED MAIN CONTENT

    <div id="posts" class="regions">
        <?php query_posts("posts_per_page=1"); ?>
        <h4><span>Blog</span> City</h4>
        <div id="post_content">
            <p><?php the_date(); ?></p>
            <img src ="<?php bloginfo('template_directory'); ?     >/images/midpic.jpg" width="200px" height="118px"/> 
            <h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
            <p><?php the_excerpt(); ?></p>
        </div>
    </div>


<!--<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar   Widgets')) : else : ?>-->
    <!-- All this stuff in here only shows up if you DON'T have any widgets active in this zone --> 
<!--<?php endif; ?>-->


</section> <!--End of Section-->

<?php get_sidebar(); ?>

<?php get_footer(); ?> 

所以我的问题是博客和日期在不正确时显示,但现在它在 home.php 中并且格式正确,php the_date 和 php the_excerpt 没有显示。关于哪个页面显示我的博客的任何规格?仅供参考,我在 index.php 和 home.php 中都试过了,没有骰子。但是,如果我将主要内容放回侧边栏中,一切都很好。任何指针将不胜感激。

4

1 回答 1

0

也许我错过了一些东西,但是 home.php 是用来做什么的?通常单个帖子模板文件称为single.php。

此外,对于完整的帖子,您应该使用<?php the_content(); ?>.

关于the_excerpt()the_content()的文档。

于 2013-02-07T01:49:45.463 回答