2011-12-29 122 views
0

您使用什麼樣的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的第一次。

謝謝!

回答

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主題。

+0

謝謝!有效! – FNMT8L9IN82 2012-01-01 04:28:54