Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
Wordpress

WordPress: Create Custom Post Types for Portfolios, Products, Reviews

- 22.03.26 - ErcanOPAK

📦 Beyond Posts and Pages

WordPress has Posts and Pages. You need Portfolios, Products, Team Members? Custom Post Types unlock unlimited content structures.

What Are Custom Post Types?

Think of them as custom content containers with their own admin interface, taxonomies, and templates.

💡 Use Cases

  • Portfolio: Projects with client, year, category
  • Products: E-commerce items (or use WooCommerce)
  • Team Members: Staff bios with role, department
  • Testimonials: Client reviews with rating, company
  • Events: Calendar items with date, location, tickets
  • Recipes: Cooking instructions with ingredients, prep time

Create Custom Post Type (Code Method)

// Add to functions.php or custom plugin

function create_portfolio_post_type() {
    register_post_type('portfolio',
        array(
            'labels' => array(
                'name' => 'Portfolio',
                'singular_name' => 'Portfolio Item',
                'add_new' => 'Add New Project',
                'add_new_item' => 'Add New Portfolio Item',
                'edit_item' => 'Edit Portfolio Item',
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'portfolio'),
            'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),
            'menu_icon' => 'dashicons-portfolio',
            'show_in_rest' => true, // Gutenberg support
        )
    );
}
add_action('init', 'create_portfolio_post_type');

Result: New “Portfolio” menu appears in WordPress admin. Add portfolio items like posts.

Add Custom Taxonomies

// Add categories and tags for Portfolio

function create_portfolio_taxonomies() {
    // Portfolio Categories
    register_taxonomy(
        'portfolio_category',
        'portfolio',
        array(
            'label' => 'Portfolio Categories',
            'hierarchical' => true, // Like categories
            'show_in_rest' => true,
        )
    );
    
    // Portfolio Tags
    register_taxonomy(
        'portfolio_tag',
        'portfolio',
        array(
            'label' => 'Portfolio Tags',
            'hierarchical' => false, // Like tags
            'show_in_rest' => true,
        )
    );
}
add_action('init', 'create_portfolio_taxonomies');

🔌 Plugin Method (No Code)

Custom Post Type UI plugin → Visual interface to create CPTs

  1. Install “Custom Post Type UI” plugin
  2. CPT UI → Add/Edit Post Types
  3. Fill in labels, slug, options
  4. Click “Add Post Type”
  5. Done! No coding needed

Display Custom Posts in Theme

// Create template: archive-portfolio.php



Our Portfolio

'portfolio', 'posts_per_page' => 12, 'orderby' => 'date', 'order' => 'DESC' ); $portfolio_query = new WP_Query($args); if ($portfolio_query->have_posts()) : while ($portfolio_query->have_posts()) : $portfolio_query->the_post(); ?>

View Project

🎯 Advanced: Custom Fields

Add custom data to your CPT with Advanced Custom Fields (ACF) plugin:

  • Portfolio: Client Name, Project Year, Website URL
  • Team Member: Job Title, Email, Phone, LinkedIn
  • Event: Event Date, Location, Ticket Price
  • Recipe: Prep Time, Cook Time, Servings, Ingredients

💡 Best Practices

  • Slug naming: Use singular (portfolio, not portfolios)
  • Enable REST API: ‘show_in_rest’ => true for Gutenberg/API access
  • Archive pages: ‘has_archive’ => true to get yoursite.com/portfolio
  • URL structure: Use ‘rewrite’ to customize URLs
  • Icon: Choose from Dashicons for recognizable menu icon

“Client wanted portfolio showcase separate from blog. Created custom post type with categories for Web, Branding, Photography. Now they manage it themselves. Clean, organized, professional.”

— WordPress Developer

Related posts:

WordPress REST API Returns 401 Only in Production

WordPress: Hide Version Number to Stop Bot Scanners

Stop Installing Plugins for Simple Redirects

Post Views: 6

Post navigation

Photoshop: Use Adjustment Layers for Non-Destructive Color Correction
WordPress: Enable Object Caching with Redis for 10x Performance

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

June 2026
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  
« May    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (953)
  • How to add default value for Entity Framework migrations for DateTime and Bool (882)
  • Get the First and Last Word from a String or Sentence in SQL (838)
  • How to select distinct rows in a datatable in C# (808)
  • How to make theater mode the default for Youtube (806)
  • Add Constraint to SQL Table to ensure email contains @ (580)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (579)
  • Average of all values in a column that are not zero in SQL (538)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (506)
  • Find numbers with more than two decimal places in SQL (454)

Recent Posts

  • C#: Use String Interpolation Instead of Concatenation
  • C#: Use Tuples to Return Multiple Values from Methods
  • SQL: Use ISNULL and NULLIF for Smart NULL Handling
  • .NET Core: Use Data Annotations for Model Validation
  • Git: Use Git Clean to Remove Untracked Files
  • Ajax: Add Custom Headers to Fetch Requests
  • JavaScript: Use console.table to Display Arrays as Tables
  • HTML: Use Spellcheck Attribute to Enable Browser Spell Check
  • CSS: Use user-select to Prevent Text Selection
  • Windows 11: Use Snipping Tool for Instant Screenshots

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (953)
  • How to add default value for Entity Framework migrations for DateTime and Bool (882)
  • Get the First and Last Word from a String or Sentence in SQL (838)
  • How to select distinct rows in a datatable in C# (808)
  • How to make theater mode the default for Youtube (806)

Recent Posts

  • C#: Use String Interpolation Instead of Concatenation
  • C#: Use Tuples to Return Multiple Values from Methods
  • SQL: Use ISNULL and NULLIF for Smart NULL Handling
  • .NET Core: Use Data Annotations for Model Validation
  • Git: Use Git Clean to Remove Untracked Files

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com