Deepak Lamichhane
Deepak Lamichhane

Reputation: 22644

how to put posts on different pages in wordpress

I find difficulties on putting the posts on different pages.

Lets suppose I have 5 pages and 10 posts. And I need to put the 1 post to each page i.e ( For e.g. 1st post to 1st page, 2nd post to 2nd page), and also i had a blog section where i have to put only the remaining 5 posts. But the blog section automatically puts all the 10 posts in the blog section.

How to solve this. Any idea would be greatful.

Upvotes: 0

Views: 1238

Answers (1)

bizzr3
bizzr3

Reputation: 1955

you can use this :

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

you can use this parameters for checking wich pages you are in :

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.

also look at this codes (get posts by slugs) :

<?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;
}
?> 

Good Luck

Upvotes: 1

Related Questions