Site logo

Archived topic

How to ad custom post type for projects

7 replies · Started by Robert on March 9, 2017

Viewing posts 1–8 of 8

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.

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

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

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.

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

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

get_template_part( 'content', 'project' );

This archived topic is closed to new replies.