Pagination for CPT's

Hey Jan, Ian pinged me tonight and let me know that there may be a question I could help with. There are of course two ways to do this: code it, or use a post grid plugin that will display posts to include custom post types you create with various forms of pagination, including the standard WP pagination routine.

Are you specifically having difficulty attaching custom PHP from Pinegrow into the proper position in the DOM? Because the trick I’ve used is to create an empty DIV and then apply custom PHP with the option to replace the entire element, and that way, you can insert whatever you’d like. Also, setting up the query properly is key.

For example, on my new site (the newest example I have, as I just pushed it to the production server to finish working on media queries):

<?php
                       $quickProjects_args = array(
                       'post_type' => array('projects', 'agency'),
                       'nopaging' => true,
                       'posts_per_page' => '4',
                       'orderby' => 'rand'
                       )
?>

This is pulling a query from a custom post type, to display 4 random portfolio items on my front page from both ‘projects’ and ‘agency’ work types. If you setup the custom post type query, you should be able to hook in standard pagination based on the query name.

You can reference this great page for explanations of the WP query parameters, which will help you understand those options in Pinegrow:

https://www.billerickson.net/code/wp_query-arguments/

Also, check out this thread I commented on regarding pagination… there are some important parameters that need to be set that are not apparent to new users in Pinegrow:

https://forum.pinegrow.com/t/master-child-pages-in-pgwp/1897/7

I hope this helps!

2 Likes