• So I’m trying to figure out two things:
    1. How to display the latest post differently than all the other posts. I don’t me mean STYLED differently, but structured differently (date, title, excerpt, and thumbnail in a different order than the other posts).
    2. I keep on coming into the problem of pagination not being there with the ways that I’ve tried. I’m trying to keep 3 posts to a page, too.

    I am trying to do this on the index.php, so I can use the traditional loop as well as the query.

Viewing 1 replies (of 1 total)
  • I would use a separate featured post query for the one most recent post. Here is an article that explains how to do it. Put the second query before the main WordPress loop.

    https://weblogtoolscollection.com/archives/2008/04/13/define-your-own-wordpress-loop-using-wp_query/

    Replace this line
    $recentPosts->query('posts_per_page=5');
    with this
    $recentPosts->query('posts_per_page=1');

    Modify the code in the article so the date, title, excerpt, and thumbnail for that post are displayed as you want them to be. If you also want it styled differently, you can wrap all of that output in a div, like

    <div class="featured">
    ---- featured post display code here  ---
    </div>

    and create the special styling for it in your stylesheet

    You will likely have to wrap the custom query loop in an if statement so it only displays on page one when the main loop has more than one page of output.

    ————-

    Now, before the main WordPress loop (which starts with something like this)

    <?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>

    put a query_posts statement to skip over the first post, as that post was already displayed in the custom query you added. You also need to tell WP you want to use paging and you want 3 posts per page.

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts("posts_per_page=3&offset=1&paged=$paged"); ?>

    This tells WP you want to use paging, offset=1 means skip the first post, and you want 3 posts per page. The first page will have 4 posts, one from the custom query that displays the most recent post plus 3 from the main query loop.

Viewing 1 replies (of 1 total)
  • The topic ‘Latest Post Issue’ is closed to new replies.