background preloader

Custom Post Types

Custom Post Types
Languages: English • 日本語 • Português do Brasil • Nederlands • Slovenčina • (Add your language) WordPress can hold and display many different types of content. A single item of such a content is generally called a post, although post is also a specific post type. Internally, all the post types are stored in the same place, in the wp_posts database table, but are differentiated by a column called post_type. WordPress 3.0 gives you the capability to add your own custom post types and to use them in different ways. Default Post Types There are five post types that are readily available to users or internally used by the WordPress installation by default : Post (Post Type: 'post') Page (Post Type: 'page') Attachment (Post Type: 'attachment') Revision (Post Type: 'revision') Navigation menu (Post Type: 'nav_menu_item') Post Post in WordPress is a post type that is typical for and most used by blogs. Page Page in WordPress is like post, but it lives outside the normal time-based listings of posts.

Function Reference/register post type Function Reference/register post type Languages: English • 中文(简体) • 日本語 • (Add your language) Description Create or modify a post type. register_post_type should only be invoked through the 'init' action. It won't work at all if called before 'init', and aspects of the new post type will work incorrectly if called later. Taxonomies When registering a post type, always register your taxonomies using the taxonomies argument. Even if you register a taxonomy while creating the post type, you must still explicitly register and define the taxonomy using register_taxonomy(). Reserved Post Types The following post types are reserved and used by WordPress already. post page attachment revision nav_menu_item In addition, the following post types should not be used as they interfere with other WordPress functions. action order theme In general, you should always prefix your post types, or specify a custom `query_var`, to avoid conflicting with existing WordPress query variables. Usage Parameters $args

Building a Site with New WordPress 3.0 Content Types: Part 1 of Several I’ve been happily tinkering with the beta version of WordPress 3, down in the bowels of the code, mixing unmarked vials of PHP over open flames, etc for a brand new NMC site. The main thing I have been working on are exploiting the feature to create my own types of content with their own properties. Essentially up to know you could create two kinds of content- posts and pages, with pretty much the same feature. Any additional descriptors one wanted to add needed to be done via custom fields. The idea is now, I could create a kind of content, say to build an encyclopedia of dogs, and use all of the WordPress features to make an entry (title, post/content, tags). But to my Dog content type, I could also add additional fields, like radio buttons to classify them by “small”, “medium”, or “large”, a field to enter a URL for an outside reference, a menu to classify my breed, etc. I will first show and talk about the (almost, ’cause its never quite done) final site. A few notes about this site:

Put on Your HazMat Suits- Setting Up Metadata For WordPress 3 Custom Content Types cc licensed flickr photo shared by StayRAW In the previous posts in this series of using the new WordPress 3 Custom Post Types (I keep calling them custom content types, same thing), I overviewed the plans for the MIDEA web site, we set up the places to create the new content types, and diverged into some set up magic using child themes. That was the easy stuff. Now I did this all in custom code, and as hopefully I stated earlier, I have no expectation that this is the way it will be dobe going forward. So returning to our functions.php editing, the first thing we need to do is to activate the bits to turn on the lights inside the WordPress dashboard; adding in the top sequence of our code: 2.add_action("admin_init", 'midea_admin_init'); which again, puts a “hook” in the wordpress flow to include the admin functions I want to add. 1.function midea_admin_init() { 3. add_meta_box("org-meta", "MIDEA Organization Details", midea_org_options, 'org', 'normal', 'low'); 03. global $post; 09. 13. 06.

Custom Post Types in WordPress 3.0 I know it’s too early to speak about WordPress 3.0, but I’ve been playing around with some of it’s enhancements the other week, and.. Well, this is a miracle, really. Remember all those plugins promising custom post types in versions prior to 3.0. In version 3.0 the developers of WordPress introduce the custom post types. Well, first I’d like to share a few thoughts of what could be accomplished using these custom post types, and I think that some of the first ones to appear would be Photo PostsQuotesChatsAudio/Podcastsand of course Video These are basically the things that you’re allowed to post at Tumblr, but hey? Why would we want to play around with custom fields, or add stupid meta boxes in the Edit Posts page and then teach our clients and/or content managers to use them? For instance, why should the Edit Post page contain the ability to attach an audio file if it won’t be used 50% of the time? John, could you please add a new Podcast? Instead of See what I mean? Amazing! Oh my god!

Extending Custom Post Types in WordPress 3.0 In a previous article about Custom Post Types in WordPress 3.0 I outlined one of the most exciting features coming up in 3.0 and I noticed that people have already started building websites upon these new features. It’s not a secret that I’m working on a project myself which involves 3.0 so just like everybody else, I can’t wait to see it being released! My project involves a custom post type for real estate and in this post I’d like to show you some tricks on: Working with custom post types and permalinks (a.k.a the 404 issue)Using WP_Query to find your custom-typed postAdding custom meta boxes to your edit post screen We’ll deal with more code than images today so get a clean copy of WordPress 3.0 (Nightly build) to experiment upon. Permalinks with Custom Post Types This is one side of the feature which is not thoroughly explained in the source code, and I’ve seen many people end up with 404 pages while their permalinks point correctly. Straightforward. WP_Query and Custom Post Types

Related: