Forums

[resolved] Can't show all posts in widget on single post (3 posts)

  1. Stefine
    Member
    Posted 8 months ago #

    Hi,
    I tried to build a widget which display my recents posts with thumbnails in the sidebar.
    On index, the widget works perfectly but on single post page , I just can view the current post thumbnails but I want to view all.

    Please,how I can do?

    [Large code excerpt removed by moderator per forum rules. Please use the pastebin for all large code excerpts. It works better anyway.]

  2. nsathees
    Member
    Posted 8 months ago #

    Has to do with the post query.

  3. Stefine
    Member
    Posted 8 months ago #

    Ok, I understood my query was on curent page. I change the following code :

    <?php $i = 1; while (have_posts() && $i <= 6) : the_post(); ?>
    ......
    <?php $i++; endwhile; ?>

    by

    <?php
     global $post;
     $myposts = get_posts('numberposts=6&orderby=post_date&order=DESC');
     foreach($myposts as $post) :
     ?>
    ...
     <?php endforeach; ?>

    Thanks for quick reply.

Reply

You must log in to post.

About this Topic