2011-12-25 71 views
0

我發現將帖子置於不同頁面上存在困難。如何在wordpress中的不同頁面上發佈帖子

讓我們假設我有5頁和10個職位。我需要在每個頁面上放置1篇文章,例如(例如第1篇文章到第1頁,第2篇文章到第2頁),還有一個博客部分,我只需要放置剩下的5篇文章。但博客部分會自動將所有10個帖子放入博客部分。

如何解決這個問題。任何想法都會很棒。

回答

1

您可以使用此:

if (is_page()) { 
    query_posts('cat=3&year=2004'); 
} 

您可以使用此參數檢查至極頁你在:

is_page(); 
// When any single Page is being displayed. 

is_page(42); 
// When Page 42 (ID) is being displayed. 

is_page('Contact'); 
// When the Page with a post_title of "Contact" is being displayed. 

is_page('about-me'); 
// When the Page with a post_name (slug) of "about-me" is being displayed. 

is_page(array(42,'about-me','Contact')); 
// Returns true when the Pages displayed is either post ID 42, or post_name "about-me", or post_title "Contact". Note: the array ability was added at Version 2.5. 

也看看這個代碼(由蛞蝓獲得職位):

<?php 
$the_slug = 'my_slag'; 
$args=array(
    'name' => $the_slug, 
    'post_type' => 'post', 
    'post_status' => 'publish', 
    'showposts' => 1, 
    'caller_get_posts'=> 1 
); 
$my_posts = get_posts($args); 
if($my_posts) { 
echo 'ID on the first post found '.$my_posts[0]->ID; 
} 
?> 

好運

相關問題