Create a Custom Post Type in Your WordPress Theme
In order to create and use custom post types on your WordPress website, you need to be sure that your WordPress theme contains the correct code and functions. In the following steps, you create a very basic and generic custom post type called Generic Content, and you also find detailed information on the different parameters you can use with custom post types to create different types to suit your needs:
In your Dashboard, choose Appearance→Editor link.
The Edit Themes page opens.
Click the Theme Functions template link to open the functions.php file.
The Theme Functions template opens in the text editor in the middle of the page.
Add the custom post type code to the bottom of the theme functions template file.
Scroll down to the bottom of the functions.php file and include the following code to add a Generic Content custom post type to your site:
// ADD CUSTOM POST TYPE
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'generic-content',
array(
'labels' => array(
'name' => __( 'Generic Content' ),
'singular_name' => __( 'Generic Content' )
),
'public' => true
)
);
}
The function register_post_type(); can accept several arguments and parameters, which is detailed in the table. You can use a variety and a combination of arguments and parameters to create a specific post type. You can find more information on custom post types and using the register_post_type(); function on the WordPress Codex page.
Click the Update File button to save the changes made to the functions.php file.
Arguments and Parameters for register_post_types();
| Parameter |
Information |
Parameters |
Example |
| label |
The name of the post type |
None |
'label' => __( 'Generic Content' ), |
| singular_label |
Same as label, but in singular, not plural format (Posts become
Post, for example) |
None |
'singular_label' => __( 'Generic Content' ), |
| description |
The description of the post type; displayed in the Dashboard to
represent the post type |
None |
'description' => __( 'This is a description of the Generic
Content type' ), |
public
show_ui
publicly_queryable
exclude_from_search |
public sets whether the post type is
public.
show_ui either shows admin screens or
doesn’t.
publicly_queryable allows this post type
to be included in public queries within template code.
exclude_from_search either shows post
type in search results or doesn’t. |
true or false (default) |
'public' => true,
'show_ui' => true,
'publicly_queryable' => true,
'exclude_from_search' => false, |
| menu_position |
Sets the position of the post type menu item in the Dashboard
navigation menu; by default, custom post types appear after the
Comments menu in the Dashboard. |
Default: 20; sets integers in intervals of 5 |
'menu_position' => 25, |
| menu_icon |
Defines a custom icon (or graphic) to the post type menu item
in the Dashboard navigation menu; creates and uploads the image
into the images directory of your theme
folder |
None |
'menu_icon' => get_stylesheet_directory_uri() .
'/images/generic-content.png', |
| hierarchical |
Tells WordPress whether to display the post type content list
in a hierarchical manner |
true or false; default is true |
'hierarchical' => true, |
| query_var |
Controls whether this post type can be used with a query variable, such as query_posts |
true or false; default |
'query_var' => true, |
| capability_type |
Defines permissions for users to edit, create, or read the
custom post type |
post (default); gives the same
capabilities for those who can edit, create, and read blog
posts |
'query_var' => post, |
| supports |
Defines what meta boxes, or modules, are available for
this post type in the Dashboard |
title (text box for title); editor (text box for content); comments (check boxes to toggle comments);
trackbacks (check boxes to toggle
trackbacks); revisions (allows
revisions); author (drop-down box to
define author); excerpt (text box for
excerpt); thumbnail (featured image
selection); custom-fields (custom fields
input area); page-attributes (page parent
and Page template drop-down lists) |
'supports' => array( 'title', 'editor', 'excerpt',
'custom-fields', 'thumbnail' ), |
| rewrite |
Rewrites the permalink structure for the post type |
true or false; slug
(permalink slug to prepend custom post types); with_front (if you’ve set permalink
structure with a specific prefix) |
'rewrite' => array( 'slug' => 'my-content', 'with_front'
=> false ), |
| taxonomies |
Uses existing WordPress taxonomies (category and tag) |
Category post_tag |
'taxonomies' => array( 'post_tag', 'category'), |
| <Tip> |
If you don’t feel up to writing all this code in the theme functions file, the Custom Post Type UI plugin from WebDevStudios provides you with an easy interface in your WordPress Dashboard. This plugin also simplifies the creation of custom post types on your site and bypasses the need to create the code in the Theme Functions (functions.php) file. You can find the free plugin.

Blogging & Social Networking Glossary
archive
1. (noun) A list of previous blog posts, in chronological order. 2. (verb) To place files or blog posts in a safer place (on DVD or another server) for longer-term or backup storage.

Blogging & Social Networking Glossary
attribute
Used in an HTML tag to give an instruction to a Web browser. For example, in This link goes to <a href="http://www.google.com">Google</a>, the <a> tag gets an attribute (href) and a value ("http://www.google.com") to go along with the basic tag. In this case, the attribute indicates to the browser that what comes next is a hypertext reference — in this case, a Web page.

Blogging & Social Networking Glossary
blacklist
An often-centralized list of e-mail addresses, URLs, and IP addresses used by spammers that are then forbidden in any blog post on your blog. With an up-to-date blacklist, a lot of spam is stopped before it becomes a comment.

Blogging & Social Networking Glossary
block
To stop all contact with a MySpace user. He can’t comment on your blog page or send you any message that you actually receive.

Blogging & Social Networking Glossary
blog
A combination of the words Web and log. Bloggers (individuals, groups, or businesses) post a chronological log of information. Content is determined entirely by the author(s) of the blog; many are personal journals.

Blogging & Social Networking Glossary
blog post
An entry in a blog, possibly containing text, images, and other media.

Blogging & Social Networking Glossary
blogger
The author of a blog.

Blogging & Social Networking Glossary
blogging policy
Outlines what you’re allowed to post in your blog.

Blogging & Social Networking Glossary
blogging software
Technology that enables you to blog. Can be either hosted or nonhosted.

Blogging & Social Networking Glossary
blogroll
A collection of links used or recommended by a blogger.

Blogging & Social Networking Glossary
cookie
A short piece of computer code, stored on your computer, that enables Web sites to remember certain settings and information the next time you visit that site.

Blogging & Social Networking Glossary
Dashboard
A kind of control panel in Blogger that shows you the blogs you’ve set up, giving you access posting, using help resources, or even creating another blog.

Blogging & Social Networking Glossary
definition list
A type of HTML list that gives a term and then its definition and has built-in spacing to lay out those elements properly.

Blogging & Social Networking Glossary
disk space
Amount of room available on your hard drive.

Blogging & Social Networking Glossary
domain
A domain is the address, or main URL, that people type in the browser to get to your Web site. The domain name you choose can’t be used by anyone else.

Blogging & Social Networking Glossary
domain registrar
A service that enables you to register a domain name.

Blogging & Social Networking Glossary
entry
An single posting in a blog containing text, images, or other media, or any combination of those things.

Blogging & Social Networking Glossary
Facebook
A social-networking service that enables you to keep in contact with families and friends via the Web.

Blogging & Social Networking Glossary
Flickr
A Web site that allows you to share, organize, edit, and otherwise manage your photos.

Blogging & Social Networking Glossary
Friend List
Your virtual online address book in MySpace. You can become someone’s friend by either sending a fellow MySpacer a Friend Request or by being on the receiving end of a Friend Request from another MySpace user.

Blogging & Social Networking Glossary
hosted services
Manages the data, software, and Web hosting of a blog; the blogger just manages the content.

Blogging & Social Networking Glossary
HTML
The computer coding used by Web designers to create Web pages.

Blogging & Social Networking Glossary
hyperlink
A navigation tool that allows a user to go from one Web location to another by clicking. Hyperinks (or just links) are typically underlined.

Blogging & Social Networking Glossary
hypertext reference
In HTML, the address that a hyperlink connects to when clicked. For example, in This link goes to <a href="http://www.google.com">Google</a>, the hypertext reference (href) is http://www.google.com. Hyperlink references can also jump to new positions on the same page, open a new e-mail message, or begin a file download.

Blogging & Social Networking Glossary
link
Short for hyperlink, a navigation tool that allows a user to go from one Web location to another by clicking. Links are typically underlined.

Blogging & Social Networking Glossary
Mom test
A self-test that flags inappropriate blog posts. If you’d let your mom read the post, then it’s probably passed the Mom test. Specifically, don’t blog about topics you think will hurt others; don’t blog about others without their permission, even about topics you consider inconsequential; and don’t identify friends and lovers by name without their permission.

Blogging & Social Networking Glossary
MySpace
A social-networking service that enables you to keep in contact with families and friends via the Web.

Blogging & Social Networking Glossary
MySpace profile
Your MySpace identity. It can contain as much or as little information about you as you’d like.

Blogging & Social Networking Glossary
news aggregation
The ability to aggregate news by using RSS feeds. Having a news aggregator included with your blog package allows your site to pull in information from another blog.

Blogging & Social Networking Glossary
nonhosted service
Blog software that you set up on your own Web server. It allows you to take on all responsibilities related to maintaining your blog.

Blogging & Social Networking Glossary
ordered list
Contains items that must be listed in a particular order, such as a list of ranks or preferences. It may also indicate a list of steps for the reader to follow.

Blogging & Social Networking Glossary
pinging
An automated notification system for search engines and newsreaders, letting those services know that your blog has been updated. A ping occurs when one computer asks another whether it’s there; the second computer confirms its presence.

Blogging & Social Networking Glossary
post
1. (noun) An entry in a blog containing text, images, other media, or any combination of these. 2. (verb) The act of creating and/or uploading a blog entry.

Blogging & Social Networking Glossary
private profile
A MySpace profile that’s limited on who can view it, such as only people on your Friend List.

Blogging & Social Networking Glossary
public domain
The status of publications, processes, and product designs that are free from copyrights and/or patents and are available for anyone's use.

Blogging & Social Networking Glossary
social network
A service, such as Facebook or MySpace, that enables to keep in touch with people you know — and meet people you don’t know.

Blogging & Social Networking Glossary
spam
Unsolicited electronic messages sent in bulk that may be commercial, nonsensical, or malicious. In addition to e-mail spam, blog comments and blog forums can be targeted by spammers.

Blogging & Social Networking Glossary
tag
A relevant keyword associated or assigned to a piece of information, such as an image, a blog entry, or a video clip. Tags are usually chosen informally by the content creator or by the online community; they help give content to nontext media and organize information for ease of searching.

Blogging & Social Networking Glossary
Trackback
A technology that tracks references to a blog posting that occurs on other blogs. They allow bloggers to link to blog posts on related topics.

Blogging & Social Networking Glossary
transparent
1. Being honest and truthful on your blog. Also means that you admit mistakes and engage in dialogue with readers who leave comments. Considered proper blogging etiquette. 2. Integration of applications, programs, and media from different sources in such a way that the end user is unaware that the content is not self-contained.

Blogging & Social Networking Glossary
unordered list
unordered list is a series of bulleted items and is used for lists that don’t require numbering.

Blogging & Social Networking Glossary
video blog
A blog consisting of video files, or the practice of placing a video file in a blog post.

Blogging & Social Networking Glossary
video-sharing service
A service, such as YouTube, that enables you to share video with others.

Blogging & Social Networking Glossary
Web host
The Web server where you software, graphics, and other files live online.

Blogging & Social Networking Glossary
Web server
Technology that looks at what Web page is requested and then feeds the browser the appropriate file. It does most of the hard work of serving Web pages to visitors coming to your Web site.

Blogging & Social Networking Glossary
whitelist
A list of preselected users who are allowed to comment on your blog.

Blogging & Social Networking Glossary
YouTube
A video-sharing service.