Forums

[resolved] GET_POSTS 1st 2nd 3rd post (4 posts)

  1. ohdiesel
    Member
    Posted 2 years ago #

    Hello,

    Can someone tell me how I can show the first, second, third, fourth, fifth latest posts using get_posts?

    I have 5 columns on my page using the following code for each list item:

    <?php $feature_post = get_posts( 'numberposts=2&order=ASC&orderby=title' ); ?>

    Anyone have any idea how i can get the first column to display the latest post, while the 2nd column will have the 2nd latest, the third column to have the 3rd latest, until the 5th to have the 5th latest post, etc.

    Any ideas?

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    It might be better to tackle this using CSS rather than PHP. If you float each of your 5 post blocks left, they should automatically display in a 5 column grid on screens that are wide enough. On smaller screens, they should drop to a 4 column grid (or less) as needed. The only tricky part is fixing the height of each of the columns, so that they drop to 4 or less columns gracefully. Given that post content (and even post excerpts) can vary in length, this might take some fine tuning before you reach an acceptable figure for the height.

  3. ohdiesel
    Member
    Posted 2 years ago #

    Hello,

    Ah, you are right about that, but I think that is far too difficult for me.

    There is no easy fix with get_post?

  4. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Not really. get_posts() just defines which posts to display. It can't define how they should be displayed.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags