Forums

Displaying posts -limit (9 posts)

  1. ThorHammer
    Member
    Posted 3 years ago #

    Using 2.6.1 and a custom theme.
    On my page I display the 14 latest posts with thumbnails and so on. (1-14).

    I would like to display the following 10 posts (older posts - 15-25) just as title links on a widget at the bottom of the page. I know I must use this code to display posts:

    <ul>
    	 <?php
    	 global $post;
    	 $myposts = get_posts('numberposts=10');
    	 foreach($myposts as $post) :
    	 ?>
    	    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    	 <?php endforeach; ?>
     </ul>

    and I also know that the $offset variable must be used to limit the posts, - but how? I have read in the codex but I just dont got any smarter... With the code above I just re-display 10 of the last 14 posts already showed. Could anyone please explain me?

  2. myinstinctwaswrong
    Member
    Posted 3 years ago #

    from
    http://codex.wordpress.org/Template_Tags/get_posts

    midway down the page is a section called Parameters - in there, they mention $offset

    try

    $myposts = get_posts('numberposts=10&offset=14');

  3. ThorHammer
    Member
    Posted 3 years ago #

    Well, I tried to include the following code on my widget:

    <ul>
                 <?php
                 global $post;
                 $myposts = get_posts('numberposts=10&offset=14');
                 foreach($myposts as $post) :
                 ?>
                    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
                 <?php endforeach; ?>
     </ul>

    But it was just - blank. Nothing there. Any advice?

  4. ThorHammer
    Member
    Posted 3 years ago #

    As I thought, this task is too difficult to solve. Or... anyone, please?

  5. ThorHammer
    Member
    Posted 3 years ago #

    as you say...bump! I really need help with this one...please...

  6. ThorHammer
    Member
    Posted 3 years ago #

    Could this be because I have placed the code in a text-widget?

  7. moshu
    Member
    Posted 3 years ago #

    PHP in text widget doesn't work.

    http://wordpress.org/extend/plugins/php-code-widget/

  8. ThorHammer
    Member
    Posted 3 years ago #

    Thanks moshu, then I have to place it ouside a widget.

  9. moshu
    Member
    Posted 3 years ago #

    Didn't I just give you the link to a PHP widget?
    (I hate when people talk back before trying out what I just suggested)

Topic Closed

This topic has been closed to new replies.

About this Topic