[Resolved] Which Generatepress template to use for a custom post type loop?

Home Forums Support [Resolved] Which Generatepress template to use for a custom post type loop?

Home Forums Support Which Generatepress template to use for a custom post type loop?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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
    Daniel

    #1504919
    David
    Staff
    Customer Support
    #1505879
    Daniel

    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.

    #1506709
    Tom
    Lead Developer
    Lead Developer

    Hi 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.

    #1507337
    Daniel

    Thank you Tom!

    That was the little push I needed to make it work.

    #1508178
    Tom
    Lead Developer
    Lead Developer

    Awesome, glad I could help 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.