2014-06-24 48 views
0

我敢肯定,我在這裏錯過了一些代碼;WordPress的 - '閱讀更多'不顯示與get_page

<?php 
    $id = 38; 
    $p = get_page($id); 
    echo apply_filters('the_content', $p->post_content); 
?> 

我這裏檢查後#2,他們說我應該改變POST_CONTENT到post_excerpt。但是,當我這樣做時,我的內容就消失了。

我想使用WP UI中的讀取更多插入按鈕。

也許我需要改變一下代碼或添加一些東西到functions.php?

無論如何感謝提前的任何答覆。

-R

回答

0

get_page功能已被棄用,使用標準WP_Query。 「閱讀更多」標籤does not work在「頁面」中,它必須手動啓用,並且它必須在循環內。循環的另一個好處是可以設置全局發佈數據,因此您可以在當前發佈的上下文中自由使用Template Tags

<?php 
    $query = new WP_Query('post_type=page&p=38'); 
    while ($query->have_posts()) : $query->the_post(); 
     global $more; $more = 0;    
     the_content(); 
    endwhile; 
?> 
+0

偉大的,那個作品,只是想知道,但你可以改變更多的文字?例如,「閱讀更多..」而不是「(more ..)」? – Rudolf

+0

@Rudolf,只需使用'the_content('Read more ...');',查看[documentation](http://codex.wordpress.org/Function_Reference/the_content)。如果這個答案有幫助,考慮[接受答案](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) – Danijel