[Support request] How to ad custom post type for projects

Home Forums Support [Support request] How to ad custom post type for projects

Home Forums Support How to ad custom post type for projects

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #289393
    Robert

    Hi, from what I can tell GP Pro does not have custom post type for portfolio/projects? WHats the best/easiest way to add this in?

    Thanks.

    #289476
    Tom
    Lead Developer
    Lead Developer

    That’s correct.

    You can create a custom post type using a plugin like this: https://wordpress.org/plugins/custom-post-type-ui/

    Let me know if you need more info 🙂

    #291485
    David Sutherland

    Hello… I am going to join in as I am also working on a project management system for my company. Two other suggestions for creating the custom post type are WP-Types (Toolset) and Pods Framework. Both of these go far beyond just creating the CPT and in my case essential.

    My question pertains to the best way to go about setting up the archive and single pages specifically for the Projects post type. I imagine that these would need to be hard coded in the child theme. Is there any further info regarding this as it specifically relates to the GP Theme?

    Kind Regards,
    Dave

    #291631
    Tom
    Lead Developer
    Lead Developer

    GP will handle the templates by default, but if you need to customize them, then you would need to add the files to your child theme using the correct naming structure: https://codex.wordpress.org/Post_Type_Templates

    #293538
    David Sutherland

    Hi Tom… I am using custom post types and I want to customize both the Archive as well as the Content in the loop. For example purposes lets use “Project” as my custom post type.

    1. In my child theme I would need an archive-project.php file and a content-project.php file.?

    2. After some time trying to get this to work I see you are using get_post_format() in the main archive.php file. After copying into my child theme and renaming I changed it to get_post_type(). Is this correct as I am trying to display the archive and content for the project CPT?

    Kind Regards,
    Dave

    #293683
    Tom
    Lead Developer
    Lead Developer

    archive-project.php would handle your archives for the post types (blog page etc..). Things like the blog, categories, tags would fall back to this file if they didn’t have their own files (category-project.php etc..).

    Then you would have single-project.php for your single posts.

    get_post_type() simply outputs the current post type – it’s meant for checking (if post type is projects, do this).

    You would use the standard functions you already see in archive.php and single.php to display your content.

    #294091
    David Sutherland

    Hi Tom… After rereading my previous post I don’t believe I was entirely clear. My question has to do with the section of code, see below, from the archive.php file that I copied to use as my starting point for my Project CPT Archive.

    <?php
    /* Include the Post-Format-specific template for the content.
    * If you want to override this in a child theme, then include a file
    * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    */
    get_template_part( 'content', get_post_format() );
    ?>

    You will notice that the above code from the copied archive.php file uses get_post_format() and the only way I can see to get my setup working so that the content-project.php is pulled into my archive-project.php file, is to use get_post_type() instead. If this change is needed then why is get_post_format() being used in the themes archive.php file that ships with the theme?

    Kind Regards,
    Dave

    #294132
    Tom
    Lead Developer
    Lead Developer

    If you have a file called content-project.php, you would replace that line with:

    get_template_part( 'content', 'project' );

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