- This topic has 5 replies, 2 voices, and was last updated 5 years, 6 months ago by
David.
-
AuthorPosts
-
May 17, 2019 at 6:35 am #902553
Dominik Mukrecki
Hi!
I would like to ask you how can I adapt appearance of custom post archive and single custom post? Changing settings via Customizer won’t affect this. I use GP child theme.
I prepared some files:
single-(here goes CPT name).php
archive-(here goes CPT name).php
content-(here goes CPT name).phpEDIT: by a CPT I mean “Custom Post Type”.
First of all I put them into main directory for a GP child theme. For example I would like to add comments link for CPT archive. The same as for blog archive. Is there any solution for example using functions.php? Or should I modify files listed above? In which way?
I achieve something using basic PHP, but if there is more sophisticated solution I will be grateful 🙂
Thanks a lot for amazing work! It seems like GP is a killer choice for all my amateur WordPress projects.
Regards,
DominikMay 17, 2019 at 3:49 pm #903150Tom
Lead DeveloperLead DeveloperHi there,
Are you only wanting to add the comments link (like regular posts) to your CPT posts? If so, that should be pretty easy to achieve without using template files.
For example:
1. Create a new Hook Element: https://docs.generatepress.com/article/hooks-element-overview/
2. Set the hook toafter_content
3. Check the Execute PHP checkbox
4. Add the comments link function to the hook content:<span class="comments-link"> <?php comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) ); ?> </span>Then set the Display Rules to your CPT archive/posts.
May 17, 2019 at 4:32 pm #903170Dominik Mukrecki
Amazing!
It worked immediately. I found that snippet in the theme files recently, but I didn’t know how to add it. It is so simple 🙂
Thank you a lot, I’ll let you know if something new is needed to improve on my site.
Regards,
DominicMay 17, 2019 at 5:12 pm #903183Tom
Lead DeveloperLead DeveloperAwesome! Glad I could help 🙂
September 19, 2020 at 2:48 am #1449652Igor
Hi, I’ve followed your instructions but I can’t get it to work. Since this is a year old post, is something changed due to newer versions of GP?
Thanks,
IgorSeptember 19, 2020 at 4:50 am #1449734David
StaffCustomer SupportHi there,
nothing has changed in GP that would affect that code from working.
Raise a new topic and explain the issue and share a link to your site and we can have a look. -
AuthorPosts
- You must be logged in to reply to this topic.