[Resolved] CPT single layout

Home Forums Support [Resolved] CPT single layout

Home Forums Support CPT single layout

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #571699
    Alvaro

    Hi,

    I need some help in finding the best way to achieve a custom layout for a custom post type single page.

    Mockup single courses

    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.

    #571998
    Tom
    Lead Developer
    Lead Developer

    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' );

    #676560
    Alvaro

    Hi,

    I realised this was still open… my fault.

    It worked. Final result: https://empower-up.pt/cursos/auxiliar-de-veterinaria/

    Thanks.

    #676810
    Tom
    Lead Developer
    Lead Developer

    Awesome 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.