Register Portfolio Custom Post Type With Taxonomy Support

Added to your child themes functions file, this code creates a custom post type named portfolio.

The code also includes support for creating custom taxonomy types for your portfolio CPT.

This code is useful when you need to modify the default labels and parameters for your CPT and Taxonomies, otherwise, you can install the Genesis Portfolio Pro plugin by StudioPress which does exactly the same thing but doesn’t enable you to modify the parameters.

Code Overview

Let me give you a brief overview of how the functions in this code work :

1. Custom Taxonomy Registration :

  • register_taxonomy('portfolio-type', 'portfolio', ...) registers a taxonomy called “portfolio-type” for the custom post type “portfolio.”
  • It includes various labels for the taxonomy, defines its behavior (hierarchical, having an archive), and sets the URL structure.
  • The taxonomy is set to be shown in the admin UI but excluded from search and tag cloud.

2. Custom Post Type Registration :

  • register_post_type('portfolio', ...) registers a custom post type named “portfolio.”
  • Similar to the taxonomy registration, it includes labels for the post type, defines its behavior (hierarchical, having an archive), sets the URL structure, and specifies supported features.
  • The post type is set to be public, with a specified menu icon.

3. Adding Filter for Portfolio Columns :

  • add_filter('manage_taxonomies_for_portfolio_columns', 'genesis_portfolio_columns') adds a filter to manage the taxonomies for the columns of the “portfolio” post type.
  • The associated function genesis_portfolio_columns adds the “portfolio-type” taxonomy to the columns.

The code essentially creates a portfolio system where items can be categorized under different types using a custom taxonomy, and these items are managed as a custom post type with specific features and behaviors.

Related Tutorials

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.