页面内容未在wordpress上显示

时间:2011-12-29 22:31:10

标签: wordpress

您使用什么样的WordPress功能来显示页面内容?

I used the_content to show the post contents, but what about the page contents? 

我已尝试过所有内容,但我找不到显示WordPress页面内容的功能。

另外,我已经创建了一个基本的page.php文件,并且在我的文件中:

 <div id="pages">
    <li><?php wp_list_pages() ?></li>
 </div>

Now, why do my index.php have my list of pages even though I didn't use the inlcude  or require function? 

请记住,我创建了自己的主题和网站,并且我第一次尝试将它放在WordPress中。

谢谢!

1 个答案:

答案 0 :(得分:0)

函数wp_list_pages()列出了所有页面。如果您想列出您应该使用的所有最新帖子

<强>的index.php

<?php get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
        <div class="entry-content">
            <?php the_content(); ?>
        </div>
    </div>
<?php endwhile; // end of the loop. ?>
<?php get_sidebar(); // If you have sidebar ?>
<?php get_footer(); ?>

<强> page.php文件

<?php get_header(); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
        <div class="entry-content">
            <?php the_content(); ?>
        </div>
    </div>
<?php endwhile; // end of the loop. ?>
<?php get_sidebar(); // If you have sidebar ?>
<?php get_footer(); ?>

请务必检查默认的twentyeleventwentyten主题,以了解如何编写WordPress主题代码。