Archived topic
CPT single layout
3 replies · Started by Alvaro on May 9, 2018
Hi,
I need some help in finding the best way to achieve a custom layout for a custom post type single page.
https://cloudup.com/cJnBzWb7AHV
I have this Courses CPT and I need the page to have two columns inside the main container. A left column (grid-30) with the featured image on top and some custom post meta below, a right column (grid-70) with the entry title, entry content and some more custom post meta.
I'm a little confused with the various hooks in the single template, and I imagine there's an easy way to achieve the layout I'm looking for.
Thanks.
Hi there,
Pretty complicated, but definitely do-able.
Basically, you would need to take this file, and name it content-yourcpt.php: https://gist.github.com/generatepress/ebe343298b30bbec84947b940c7526f0
Then, copy the single.php file and paste it into your child theme.
Name it single-yourcpt.php (https://developer.wordpress.org/themes/template-files-section/custom-post-type-template-files/) and replace:
get_template_part( 'content', 'single' );
With:
get_template_part( 'content', 'yourcpt' );
Hi,
I realised this was still open… my fault.
It worked. Final result: https://empower-up.pt/cursos/auxiliar-de-veterinaria/
Thanks.
Awesome :)