Archived topic
Archives title and items template
9 replies · Started by David on November 20, 2020
Hi,
Thanks in advance for your time!
I need to change the title of the CPT archive page from "Archives CPT" to "CPT" only.
And I need to design the way a post is showed in archive page. Now only shows the post title and the page is 100% width, so there is no any template working. How can I edit the CPT page template and the posts with photo, title and other data in archive page?
Thank you very much.
Hi there,
how have you created the CPT and its accompanying templates ?
Hi, thanks for the quick response!
The CPT is created and the CPT content is shown through a hook (generate_after_entry_content) with your Elements plugin. So I have'nt need to create template files yet.
Where is the Archives CPT title coming from? Any chance you can link us to the page?
When it comes to designing your post type, it really depends on your needs. You will likely want to create a custom template file for it.
Hi, thanks!
I have resolved the title question.
The archive of the custom post type you can see it here:
https://www.ihelp.org.es/new/reto/
I have created the archive-reto.php copying it from archive.php file and saving it in child theme. But there is no design of the archives pages. Do I have to create it from blank or there is anyway to copy-past a design of GeneratePress?
Thanks very much :)
It's actually using the same HTML markup and CSS as our regular archives. However:
1. It's full width because of this custom CSS:
body .grid-container {
max-width: 100%;
padding-top: 0px;
padding-bottom: 0px;
}
2. The posts have no content/excerpt.
3. The posts have no featured images.
If you were to resolve the above, the layout should be identical to the regular archives.
Hi Tom, thansks!
Perfect, now I understand the problem
One last answer, in archive.php exists this line of code: generate_do_template_part( 'archive' );
Where is the code of this 'archive'? I think that this would be useful to create several templates files with 'archive-CPT' and organize them.
Regards!
That code is a wrapper for this: https://github.com/tomusborne/generatepress/blob/3.0.2/inc/theme-functions.php#L587
In your case, you can just replace it if needed like this:
get_template_part( 'content', 'something' );
Ok, thanks Tom!
No problem!