2013-03-15 67 views

回答

1

我會用這樣的

參考:http://codex.wordpress.org/Template_Tags/get_posts

<?php 
global $post; 
$args = array('numberposts' => 3, 'category' => 1); 
$lastposts = get_posts($args); 
foreach($lastposts as $post) : setup_postdata($post); ?> 
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
    <?php the_content(); ?> 
<?php endforeach; ?> 
+0

謝謝。代碼執行但無論我使用哪個類別,它總是返回當前頁面,這是我測試代碼的地方。任何想法可能是錯誤的? – 4thSpace 2013-03-16 03:07:40

+0

我正在使用正確的catID,並在另一頁上嘗試了此操作。仍然會返回當前頁面。 – 4thSpace 2013-03-16 03:17:33

+0

我更新了我的答案。我只是測試和工作。您應該能夠將類別標題放在單引號中,而不是類別編號 – 2013-03-16 04:21:51