background preloader

WP Custom Types

Facebook Twitter

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. We’ve seen the register_post_type function already which is clearly explained in the Codex and even more clearly in the source code so I expect you read those bits if you haven’t.

Permalinks with Custom Post Types Straightforward. That’s it. 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. Those that never get updated and show themselves glitchy sometimes, especially during upgrades? Well the time has come. 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? John, could you please add a new Podcast? Instead of See what I mean? Now isn’t that awesome? 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 get into the parts I had to more or less invent on my own (well, with some good leg ups from others)- how to add all of the form field elements to my new content types so I could add extra information to them. This are fields for say, my Organization content types, to have a field to enter their web site address, latitude/longitude for doing some mapping, etc. 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. 2.add_action("admin_init", 'midea_admin_init'); 1.function midea_admin_init() { 01.function midea_org_fields() { 09. 13. 06.

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). My Dog content type would live outside the blog content, so they would not appear as posts, but I could create templates to display them and the additional data, I could build sidebar widgets, I can make archives, do all kinds of things. I will first show and talk about the (almost, ’cause its never quite done) final site. 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. If you do not, the taxonomies and post type will not be recognized as connected when using filters such as parse_query or pre_get_posts. 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 More information: 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.