Support » Fixing WordPress » How to call older posts using Global $post.??

  • Resolved hikzik


    Hey there.
    I’m new to wordpress, but have been trying to learn quickly to implement my own theme design to work with it.
    Have hit a little snag…and was hoping to get it done quickly.
    I am using a two column theme and have used the following query to get the code and then distribute the posts between the two columns and it works beautifully.
    The Code:
    global $post; $myposts = get_posts('numberposts=10');

    But the thing is with this code it only calls the first 10 posts and when I click on Older posts I get the same Page.

    any suggestions how to get by this.??

Viewing 3 replies - 1 through 3 (of 3 total)
  • the next pages query needs an offset of 10

    first page:

    $myposts = get_posts('numberposts=10');

    older posts page:

    $my_older_posts = get_posts('offset=10');

    and you’re saying you ‘get the same page’ does the URL change (ie: ../page/2/) or is the URL staying the same?

    sorry my bad…
    I am getting the changed url (ie: ../page/2/) as you mentioned, but my code displays the same posts.

    $my_older_posts = get_posts('offset=10');

    How should i be coding this such that WordPress understands its older pages.?
    i.e How to differentiate between First page and older pages.?
    am still a noob when it comes to wordpress.
    Thanks a lot in advance and really appreciate your help.

    @davidsword — Thanx a lot…But i found it out.
    This code worked great for me.!

        $ppp = get_option('posts_per_page');
    	if (!is_paged()) {
    		$custom_offset = 0;
    	} else
    	    $custom_offset = $ppp*($paged-1);
    	$args = array(
    	'numberposts' => $ppp,
    	'offset' => $custom_offset,
        global $post; $myposts = get_posts($args);

    For the full explanantion its down here at this link:

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to call older posts using Global $post.??’ is closed to new replies.