Adding a Portfolio Custom Post Type

This tutorial will go over the code needed to create a WordPress custom post type for a portfolio section. After you complete this tutorial, you will have a Portfolio tab in your WordPress Dashboard that will allow you to create new portfolio items.

Steps

  1. Go to Github and download the WP Custom Post Type class here.
  2. Create a new directory in the /inc/ directory called /post-types/
  3. Copy the CPT.php file from the download into the /post-types/ directory
  4. Open the functions.php file and at the bottom add the following code:

  5. Create a new file in the /post-types/ directory called register-portfolio.php with the following code:

  6. Open the functions.php file and add the following code to the bottom:

  7. Done!

Note: As always the video goes in more detail about each step in this tutorial.

Notes from the Video

You can download the WP Custom Post Type class here.

Here is a link to the WordPress codex that goes over all the different parameters you can use when creating a custom post type.

The different Dashicons that can be used can be found here.

Feedback

Please let me know what you think of this tutorial and if you need help with anything.

  • Gregg Franklin

    Matt try going to the dashboard of the site and to Settings > Permalinks and resave them.

    • Yes, resaving the Permalinks will fix this. Thanks for replying to this Gregg, I am not sure why I didn’t get notified of this comment. This was answered in the Support Forum as well.

  • Abu Jorhom

    I am half way there too. Awesome tuts Brad.

  • Michael Robichaud

    Once I add the CPT.php file my wordpress site no longer loads(blank white screen). Is anyone else seeing this? Any ideas to troubleshoot? Thank in advanced

    • Michael Robichaud

      I was able to figure out the problem. It was a rights issue to read the file under the user context running the thread.

  • thumbnail doesn’t show

    • Danuco, I can’t really help with these short statements you make in the comments.. Haha. I need a little more detail on the problem you might be having.

  • Awesome, thank you.

  • Todd Burnes

    Fantastic tutorials Brad. I’m trying to set this up for a “Team Members” section, so the filter will sort individuals as opposed to portfolio pieces. My CPT file is named “register-teammembers.php”, and I’ve translated all the neccessary post type names for the $teammembers = new CPT(array( but I’m not getting the tags to show up when I put the taxonomy info in. Here’s what it looks like:

    $teammembers->register_taxonomy(array(
    ‘taxonomy_name’ => ‘team member_tags’,
    ‘singular’ => __(‘Team Member Tag’, ‘Orion-2016’),
    ‘plural’ => __(‘Team Member Tags’, ‘Orion-2016’),
    ‘slug’ => ‘team member-tags’

    Not sure where I’m going wrong, any ideas? Thanks so much Brad!

    • Looks like you have a space in the taxonomy name that might be causing an issue. ‘team member_tags’