Site logo

Archived topic

Content specific file in archive loop for custom post types

2 replies · Started by Jean-Patrick on October 17, 2020

Viewing posts 1–3 of 3

Hi Tom, hi GPTeam, hi GPUsers.

First of all, thank you all for bringing us such an amazing tool!

Sorry if the question has already popped up, but i didn't find anything helping me out ...

I have created 4 different post types in a custom plugin, and I am now trying to customize the layout of each of them on the frontend.

I am getting quite confused with the new "generate_do_template_part()" function, as now it seems we cannot go with the single-{$slug}.php or content-{$slug}.php in our child theme anymore. Or maybe I haven't figured my way out yet. Maybe with Elements or such, but I do not get it right now ...

Is there somewhere an example of the way to deal with custom files for custom post types ? Or could someone show me an example code of a filter/action to use ?

Thank you anyway for the work you've done !

Keep going.

JPH

Hey Jean-Patrick, I'm looking for answers for a similar issue. I'm checking the " Notify me of follow-up" box to follow along. Thanks!

Hi there,

generate_do_template_part() is just a wrapper function for get_template_part(): https://github.com/tomusborne/generatepress/blob/3.0.2/inc/theme-functions.php#L576

The positive to the function is we now have actions and filters to work with so we can avoid using child themes in some cases.

However, you can replace it in your child theme with get_template_part() without any issues.

Let me know if you need more info :)

This archived topic is closed to new replies.