2012-02-09 18 views
0

我的主題支持頁面,帖子和博客類別頁面,但我指定的博客頁面不限制任何內容,它顯示了所有無論如何發佈帖子。 我已經將博客頁面設置爲僅顯示5個最新帖子。我的新WordPress主題完美工作,除了我不知道如何限制博客頁面中顯示的博客文章

我只是想讓它顯示博客文章的摘錄,在底部有一個'Read more ...'鏈接。

如何僅在博客頁面中顯示帖子的摘錄?

當前模板:

<div id="contentMain"> 
    <div class="left-section"> 
    <?php if (have_posts()) while (have_posts()) : the_post(); ?> 
    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
    <div class="body-top"></div> 
    <div class="entry-content body-content"> 
    <?php 
    if (is_page()) { 
    echo '';  
    } 
    if ((is_single()) || (is_home())) { 
    echo '<h2 class="entry-title">'; the_title(); '</h2>'; 
    } 
    ?> 
    <?php 
    if (is_page()) { 
    the_content(); 
    } 
    if ((is_single()) || (is_home())) { 
    echo '<h6>'; the_content(); '</h6>'; 
    echo '<hr />'; 
    } 
    ?>   
    <?php ?>     
    </div> 
    <div class="body-bottom"></div> 
    </div> 

    <?php endwhile; ?> 
    </div> 
    </div> 
    </div> 
    <?php get_footer(); ?> 

回答

2

使用the_excerpt()其中y你想要一個節目而不是the_content()。所以像

<?php if (is_home()) { 
    the_excerpt(); 
} else { 
    the_content(); 
} ?> 
+0

謝謝,就是這樣。 – 2012-02-09 23:32:29

0

更改此

if ((is_single()) || (is_home())) { 
    echo '<h6>'; the_content(); '</h6>'; 
    echo '<hr />'; 
} 

這個

if ((is_single())) { 
    echo '<h6>'; the_content(); '</h6>'; 
    echo '<hr />'; 
} 
if ((is_home())) { 
    echo '<h6>'; the_content(); '</h6>'; 
    echo '<hr />'; 
} 

這應該可以解決你所遇到

+0

沒有注意到任何改變。我只想要列出所有博客條目的'博客'頁面顯示那裏顯示的每個最新5篇文章的摘錄。目前它顯示了全部文章。 – 2012-02-09 22:55:43

+0

對不起,我整晚都在睡覺。在8小時,如果我沒有回答,我會醒來,我會爲你找到正確的答案。 – thenetimp 2012-02-09 23:02:14

相關問題