Pinegrow Community Support Forum

Pagination for CPT's


#1

I’m having no luck at all adding pagination to custom post types. Has anyone had this issue? I’ve done a lot of research and nothing seems to work. I’ve got quite a few cpts so pagination is really important.
Any ideas would be gratefully appreciated.


#2

Hi Jan, you might also try asking Derek over on the pinegrow slack channel

https://pinegrow-webeditor.slack.com/messages/DFVNUHR2B

Derek Neuts

Im not sure if that above link will get you to him, but once in the slack room,
create a message for

@Derek Neuts

and should get it. Its currently breakfast o clock for him :slight_smile:

I think He comes here too, but I seem him mostly on slack and he is a bit of a Wordpress guru
as might be @earnoud, but he is also a Pinegrow Dev so might be a bit busy right now, with new PineGrow release etc.

and here here is Derek in the forum…


#3

Thanks Ian. I worded it slightly wrong actually, it’s a wp_query loop called category_query that’s showing posts from the “products” cpt.

All the advice out there seems correct but it’s getting the code into the loop before the ‘if have posts’ and after after the ‘end if’ before the reset. Pain in the arse is what it is mate. I think the next site I build I may try to build manually. Pinegrow has taught me enough to do that I believe and it would save time doing some of the more complicated stuff.

Cheers for referencing that guy. Ill try to message him tomorrow. I gave up on slack a while back so will have to install the app again


#4

Yes, I sort of drifted away from slack - due to the fact that they…delete you content, on a rolling basis, after 10, 000 posts. So seems like NO POINT…referencing stuff in there.
For chatting yeah or a quick answer. fine, but then…If its a long answer, its going to be lost in the future so why bother, unless you create the answer in the forum, which persists, then reference it on slack…in which case…why not just use the forum? Seems to make Slack redundant.

And as for pagination, alas I am afraid I’m of little use with Wordpress

but have you checked this chicks info out.

I really am becoming a fan of her stuff.

which followed on from this

which probably came after this :slight_smile:

…ok ok…enough already… the President has left the building

(ok a bit more…I’m going to use her stuff in order to learn how Wordpress WORKS, not just monkey see, monkey do, oh look, check box…click)


#5

I never delved into slack as much as you it seema but yes, that does kind of make it redundant.

I saw you posting her visa on here a little while ago, I’ll check them out hopefully tomorrow, cheers for the share.

With pinegrow, if you look at the php it actually puts in after you’ve point and clicked it starts make a lot more sense. That’s why I think it’s a great learning tool. I’d still need to reference the wp docs constantly without it. I just think it’s limited in some ways though. I could edit the exported php documents to complete the task I want but when you export pinegrow again, that would all be lost. It’s the little things like that that make its coverage of website building not 100%. It’s damned close though.


#6

oh well done. yeah Derek and some others I see having some proper wordpress Boffin chats on there explaining stuff and working things out. He seems very helpful with people who have problems with PG and WP> Maybe formulate a good description of what you’re trying to do and anticipated results and fire it off to him …thats if good ol’ Tania cant save ya bacon :slight_smile:

either way, welcome aboard :slight_smile:
maybe one day, I two will be feasting off the great Wp in the sky gravy train…that’s if the Gutenberg debacle doesn’t derail it and some new kid on the block rushes in to devour its omnipresence…

Its the way of the techie world.


#7

Been here for a few years bud. I’m just a lurker :wink: usually figure something out as soon as I post it on a forum. Such is life.

I’ve updated two of my sites to Guttenburg so far. No issues yet. It doesn’t seem to affect cpts, weirdly.

Anyway, the day job beckons. Thanks for the links. I’ve time to kill in Rugby later so I’ll have a watch.

Take care


#8

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!