Site logo

Archived topic

[GP Beta] generate_do_template_part does not call the content

4 replies · Started by Laurent on September 19, 2020

Viewing posts 1–5 of 5

Hi,

I'm testing GP 3.0 Beta which is great so far. However I have a problem that I can't figure out.

I've a CPT 'formation'.

In single-formation.php, if I have the line

get_template_part( 'content', 'formation' );

it displays the content as in 2.7

If I replace the line with :

generate_do_template_part( 'content', 'formation' );

It shows nothing.

What Am I doing wrong ?

Thanks

Looking into the function code, it seems it does not handle CPTs ? There's only one parameter.

Should I keep using get_template_part() for CPTs ?

I saw that but didn't understand, now I think I do.

I can either :

- keep using get_template_part within child theme templates as default wordpress behavior

or

- use generate_do_template_part, remove the child theme templates and use a add_action( 'generate_before_do_template_part', function...) which would check the post_type and displays information accordingly

Using the later opens up possibilities of calling those from Elements and other places in the code. Did I get this right ?

Thanks

Exactly! There's nothing wrong with keeping the core get_template_part() if you're already using a child theme.

generate_do_template_part() simply allows for a way to remove the default get_template_part() and add your own loop item without the need for a child theme template :)

This archived topic is closed to new replies.