- This topic has 3 replies, 2 voices, and was last updated 3 years, 4 months ago by
Fernando.
-
AuthorPosts
-
December 11, 2022 at 3:05 pm #2458256
Josh
Hi there,
I’ve been reading through some support posts and they advise us to create single-custom-post-type.php and content-custom-post-type.php files to support our custom post types.
But when I did that and tried to replace them with Content Templates in Elements, the Content Templates didn’t work until I deleted those PHP files.
So, I’m a little confused. If we can just make Content Templates, what is the point of creating the physical PHP files? Do they work with other types of elements?
Thank you for your time,
Josh
December 11, 2022 at 6:54 pm #2458370Fernando Customer Support
Hi Josh,
Content Templates should work with that setup. Perhaps you altered something in the code? It also works without those custom templates.
If you’re planning to alter the structure of your CPT single posts and archive pages code-wise, it’s good to create and use custom template files.
Otherwise, CPT end links will just use the default archive and single page/post template which is fine. Other Elements should still work.
It’s more or less preferential.
December 12, 2022 at 8:31 am #2459224Josh
Sorry, Fernando, but I’m still confused.
The GeneratePress “way” is to use Elements to create a Content Template for the archive and single post for a custom post type.
Is this correct?
When I did this the Content Template Elements worked only AFTER I deleted the PHP files associated with the custom post type.
Is that normal behavior?
Thank you again,
Josh
December 12, 2022 at 5:20 pm #2459724Fernando Customer Support
There’s no definite way to create Archive and Post templates. It all depends on your structure. But, we do recommend using a Block Element – Content Template or Loop Template if you want to extensively modify the Blog and Archive Pages. As for single Pages/Posts, it’s not conventional to use Content Templates here. We usually recommend using other types of Block Elements to build up single Posts/Pages.
As for your second inquiry, no, this isn’t normal behavior. If you directly copy and paste the templates
single.php,content-single.phpand if you prefer,archive.php, Elements should still work. With this said, did you make any edits to your CPT template files? -
AuthorPosts
- You must be logged in to reply to this topic.