Display ACF Post Type on front page with pagination

I’m trying to display a gallery of a custom post type on the front page with pagination.

If I try to use a looper provider/consumer setup on a page assigned as the front page, I can display the custom post types fine, but if my understanding is correct, the context is incorrect for the pagination to work. So, I wonder:

  • Is there a custom attribute that can be added to the pagination and/or posts element to fix the context? I’m basing this on a previous issue I faced with sliders and their navigation controls.
  • Could there be a child theme modification that could set the custom post type to be the one that the WP query fetches on the home page?

I also tried using an archive versus a standard page. The pagination does work that way, but I can’t find a way to make it the front page. (would it be possible to change the “your latest posts” code?)

I get this is not exactly how WordPress is intended to function, but I think it’s worth solving for the best user experience.

I’ll put my site info in the secure notes for you guys. Any assistance would be greatly appreciated.

Best,

Shea

Hi guys,

I wanted to share that I think? I have found a solution, but I will see if it causes unintended side-effects as I continue developing.

I added the following code to the child functions.php and set the reading setting to the front page “your latest posts”

function display_custom_post_type_on_home($query) {
    if (is_home() && $query->is_main_query()) {
        $query->set('post_type', 'items');
    }
}
add_action('pre_get_posts', 'display_custom_post_type_on_home');

Feel free to give feedback or criticism. If any issues arise, I will continue to update this post.

Hey Shea,

We’re glad that you’re able to find a solution to your issue.

Cheers!