• Resolved mikeroyerdesign

    (@mikeroyerdesign)


    I have been googling and searching for a few days now and many of the solutions I’ve come across simply won’t work. Please be patient if you have seen this question before.

    I have a custom post type called “food” and I want to show the 9 most recent posts on front-page.php and have the pagination work. I can only seem to get variations of this to work. The closest I’ve gotten is where the pagination will work, but when you proceed to page 2, index.php is used to display the paginated pages.

    This is my loop:

    <?php
    $temp = $wp_query;
    $wp_query = null;
    $wp_query = new WP_Query();
    $wp_query->query('showposts=9&post_type=food'.'&paged='.$paged); 
    
    while ($wp_query->have_posts()) : $wp_query->the_post();
    ?>
    
    <h2><?php the_title() ;?></h2>
    
    <?php endwhile; ?>
    
    <?php previous_posts_link('&laquo; Newer') ?>
    <?php next_posts_link('Older &raquo;') ?>
    
    <?php
    $wp_query = null;
    $wp_query = $temp;  // Reset
    ?>

    I will love you forever and ever if anyone can help me.

Viewing 1 replies (of 1 total)
  • Thread Starter mikeroyerdesign

    (@mikeroyerdesign)

    I believe I solved my problem. My theme was missing archive.php (currently in local development so I just hadn’t gotten around to creating it yet) and I guess it was throwing everything off.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Post Type loop WITH pagination on front-page.php’ is closed to new replies.