Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8892719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:04:37+00:00 2026-06-14T23:04:37+00:00

Instead of putting my custom post type in to my theme, I decided I’d

  • 0

Instead of putting my custom post type in to my theme, I decided I’d create a plugin (as my theme is likely to change in the future).

I created a folder for my plugin and made a file (myplugin.php) with content like:

<?php
   /*
   Plugin Name: myplugin
   Plugin URI: http://www.mywebsite.com
   Description: Custom post types for my website
   Version: 1.0
   Author: my name
   Author URI: http://www.mywebsite.com
   License: Private
   */
?>

And added my custom post type to a functions.php file, like so:

<?php
add_action( 'init', 'register_cpt_portfolio' );

function register_cpt_portfolio() {

    $labels = array( 
        'name' => _x( 'Portfolio', 'portfolio' ),
        'singular_name' => _x( 'Portfolio', 'portfolio' ),
        'add_new' => _x( 'Add New', 'portfolio' ),
        'add_new_item' => _x( 'Add New Portfolio', 'portfolio' ),
        'edit_item' => _x( 'Edit Portfolio', 'portfolio' ),
        'new_item' => _x( 'New Portfolio', 'portfolio' ),
        'view_item' => _x( 'View Portfolio', 'portfolio' ),
        'search_items' => _x( 'Search Portfolio', 'portfolio' ),
        'not_found' => _x( 'No portfolio found', 'portfolio' ),
        'not_found_in_trash' => _x( 'No portfolio found in Trash', 'portfolio' ),
        'parent_item_colon' => _x( 'Parent Portfolio:', 'portfolio' ),
        'menu_name' => _x( 'Portfolio', 'portfolio' ),
    );

    $args = array( 
        'labels' => $labels,
        'hierarchical' => true,
        'description' => 'To display completed works.',
        'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields' ),
        'taxonomies' => array( 'category' ),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,


        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => true,
        'capability_type' => 'page'
    );

    register_post_type( 'portfolio', $args );
}
?>

However, after activating the plugin, I don’t see my custom post type – have I missed any steps here? Thanks for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:04:39+00:00Added an answer on June 14, 2026 at 11:04 pm

    Instead of using a functions.php file I just put the CPT in to the main plugin php file and it seems to work well. I’ll accept this as the answer in two days when it will let me unless anyone has a better suggestion on how I should do this :).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have an idea of putting my blog on to Azure instead of a
Instead of having to type tmux every time, how could I have tmux always
I am trying to do form validation by putting the post values into variables
I have a piece of javascript: $.getJSON(something.json,function whatever(data) Instead of putting something.json in the
For the sake of better organized code, instead of putting a callback function within
VS2010 Ultimate, ASP.NET MVC 3 w/Razor. I've created a custom view engine in my
This allows me to get easyly dynamic input variables instead of putting a static
For example I have long list of buttons: <input type=button name=clickbutton onclick='dosomething(this)'> But instead
I'm investigating the possibility of putting together a custom storage scheme for my application.
How can I force flex to cuddle my curly-braces instead of putting them on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.