- This topic has 5 replies, 3 voices, and was last updated 4 months, 1 week ago by
Tom.
-
AuthorPosts
-
October 26, 2020 at 4:57 am #1504439
Daniel
Hi!
I have a CPT created with the CPT UI plugin and I want to display a custom loop on one of the pages of my website.
Which generatepress page template do I have to copy into my child theme to modify it and add the custom loop?
I tried with page.php modifying from line 29 but I get a critical error.
I’m starting with this kind of programming to learn and I just need guidance on which generatepress template is better to use to include a custom loop.
I’m using GeneratePressVersion: 3.0.2
Thanks
DanielOctober 26, 2020 at 7:58 am #1504919David
StaffCustomer SupportHi there,
If this is for the single post type – then you should use the single.php:
https://github.com/tomusborne/generatepress/blob/master/single.php
For reference:
https://developer.wordpress.org/themes/template-files-section/custom-post-type-template-files/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/October 27, 2020 at 3:07 am #1505879Daniel
Thanks David!
It isn’t for the single post type but for displaying the loop of my CPT. I mean I need a page template where I’m going to paste my custom loop which will be something like:
<?php $portafolio = new WP_Query( $args ); while ( $portafolio->have_posts() ) : $portafolio->the_post(); generate_do_template_part( 'page' ); endwhile; ?>
I’ve tried modifiying with a copy of page.php called page-portfolio.php in my child theme and I have modified this section https://github.com/tomusborne/generatepress/blob/master/page.php#L29-L36
But it didn’t work, maybe is my code which is incorrect, but I need to be sure if the template I have to modify is page.php or another.
October 27, 2020 at 10:12 am #1506709Tom
Lead DeveloperLead DeveloperHi there,
You would need to replace the following line with your custom loop:
generate_do_template_part( 'page' );
The above line is a wrapper for this:
get_template_part( 'content', 'page' );
So it’s loading the
content-page.php
file in that place of your template.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 28, 2020 at 1:48 am #1507337Daniel
Thank you Tom!
That was the little push I needed to make it work.
October 28, 2020 at 9:22 am #1508178Tom
Lead DeveloperLead DeveloperAwesome, glad I could help 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.