- This topic has 5 replies, 3 voices, and was last updated 4 months, 1 week ago by Tom.
October 26, 2020 at 4:57 am #1504439Daniel
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
DanielOctober 26, 2020 at 7:58 am #1504919DavidStaffCustomer Support
If this is for the single post type – then you should use the single.php:
For reference:October 27, 2020 at 3:07 am #1505879Daniel
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 #1506709TomLead DeveloperLead Developer
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.phpfile in that place of your template.October 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 #1508178
- You must be logged in to reply to this topic.