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. I’m not sure whether it’ll be solely built into the API or also displayed as a GUI somewhere in the settings, but it doesn’t require too much coding skills to add a couple via your functions.php or a perhaps a plugin.
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 Posts
- Quotes
- Chats
- Audio/Podcasts
- and of course Video
These are basically the things that you’re allowed to post at Tumblr, but hey? We could already post these at the standard Posts type. Exactly, we could! But the custom types perhaps is a step to more organization, rather than functionality.
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? Why not just get rid of all those stuff and have them seperately in your main menu, and the meta boxes are customized to match the exact needs of certain post types.
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? Or why would Quotes contain post revisions? Chats and Video posts wouldn’t require image posting, right? This way you can talk to your client or content manager in a certain way:
John, could you please add a new Podcast? Here’s the MP3 file.
Instead of
John, I need you to add this MP3 file as a Podcast – please add a new post, then in the box on the right you should pick that your post type is a Podcast, then a little bit lower in the next box you should upload this audio file, and also please make sure that you check the Podcasts category before you publish.
No, John, don’t touch the Video box, we use that for video posts. No, leave the custom fields as they are, you should never touch that area
See what I mean? Manipulating also comes in clean and handy. You don’t have to sort different post types into different categories, then use the Edit Posts screen and set filters to a certain category to get a list of Podcasts. Wow.. Also, once your post is a Podcast, it doesn’t hurt your eyes in the Edit Posts section, it’s not visible there at all. Once a Podcast – always a Podcast ;) Awesome isn’t it?
More awesome is the way you can customize the columns in the Edit screen to fit your needs, for each and every post type! Take a look at this Podcasts Edit screen example:
Now isn’t that awesome? I bet it is!
So what else could be done with WordPress’ Custom Post Types? Well, basically anything. Say you run an online store which of course has some static Pages (such as Contact, About, etc), some blog Posts, cause we’re so 2.0, remember? And Products, which would be a custom post type that contains the product name, description, product price, stock availability, and could even contain inquiries in forms of user comments!
One more example – a Real Estate Agency, same story – Pages, Blog Posts, News stories, property For Sale, property For Rent, Land for sale. The last three would contain extra taxonomy in forms of Country, Region. Custom fields such as price, total area, etc. The Edit Property page could even contain a Google Map where you could point out its location! Here’s a screenshot:
Amazing!
Using Custom Post Types
Yeah, all this is good, but it gets even better as soon as you find out how easy it is to define (register) Custom Post Types in WordPress 3.0! Err.. This means that you have to actually switch to 3.0 before any of this works. Read the article on Nightly Builds, switch to a 3.0-dev branch and launch an upgrade. You should be able to get 3.0-alpha by now.
So let’s try to add a Podcasts type and let’s go straight to the code:
// Fire this during init register_post_type('podcast', array( 'label' => __('Podcasts'), 'singular_label' => __('Podcast'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, 'supports' => array('title', 'editor', 'author') ));
Oh my god! Is that it? Yes! I wouldn’t like to go through the parameters but you could read about them in the WordPress Codex – Function Reference: register_post_type.
Perhaps the tricky part would be with the custom columns? Nah:
add_action("manage_posts_custom_column", "my_custom_columns"); add_filter("manage_edit-podcast_columns", "my_podcast_columns"); function my_podcast_columns($columns) { $columns = array( "cb" => "<input type=""checkbox"" />", "title" => "Podcast Title", "description" => "Description", "length" => "Length", "speakers" => "Speakers", "comments" => 'Comments' ); return $columns; } function my_custom_columns($column) { global $post; if ("ID" == $column) echo $post->ID; elseif ("description" == $column) echo $post->post_content; elseif ("length" == $column) echo "63:50"; elseif ("speakers" == $column) echo "Joel Spolsky"; }
Whoot! All done. As seen in the code above, there’s an action and a filter involved. The action outputs custom columns depending on the type, while the filter simply defines the columns for the Podcasts post type. It’s as simple as that. Note that I trimmed the code a little bit to fit on screen, so you shouldn’t be simply outputing 63:50, but actually count the podcast length ;)
That’s about it, folks! Cheers, and say, What custom post types are you thinking of implementing in the first place? Please share via the comments. Thanks!
Follow up: Extending Custom Post Types in WordPress 3.0
What a great post Konstantin! I knew all along that WordPress wasn't simply a blogging platform. There are tonnes of examples out there that are using WordPress as a CMS, and with this feature coming along it'll be even easier to customize!
Podcasts and Video posts and all the others, that's surely a way of organizing things, but the extra functionality is at the e-commerce side, as you said – Products, Real Estate, maybe also Events, Lists or Roundups, Tweets Collections, Tutorials.
P.S. According to this ticket in the WordPress Core Trac, the GUI for managing custom post types will not be built into the core, which leaves an opportunity for plugin and theme developers.
Thanks Chris, good point on that Trac ticket!
Podcasts and Video posts and all the others, that’s surely a way of organizing things, but the extra functionality is at the e-commerce side, as you said – Products, Real Estate, maybe also Events, Lists or Roundups, Tweets Collections, Tutorials.
This is great plugin, very interesting
Err, sorry, this is not a plugin, it's built into the WordPress 3.0 Core ;)
[…] Custom Post Types in WordPress 3.0 […]
[…] Custom Post Types in WordPress 3.0 […]
I couldn't figure out how to get the custom columns working, is your code correct? Copy and pasting that just gives me a blank admin screen.
Thanks, Kris
The code above is missing a quotation mark in function my_custom_columns, thats why it will result in a blank page:
To fix this, change:
function my_custom_columns($column)
{
global $post;
if ("ID" == $column") echo $post->ID;
elseif ("description" == $column) echo $post->post_content;
elseif ("length" == $column) echo "63:50";
elseif ("speakers" == $column) echo "Joel Spolsky";
}
Into:
function my_custom_columns($column)
{
global $post;
if ("ID" == "$column") echo $post->ID;
elseif ("description" == $column) echo $post->post_content;
elseif ("length" == $column) echo "63:50";
elseif ("speakers" == $column) echo "Joel Spolsky";
}
Thanks Ed, it was an extra symbol btw, not missing. Anyways it works both ways, but I prefer to keep my variables out of strings ;) Cheers!
Yieks! Sorry about that, extra symbol, fixed it now.
Interesting post!
Now the only thing i can't get my head around yet is an easy way to add custom write panels to custom post types. You seem to have done this on your Real Estate Example. Do you just use custom fields or did you make custom write panels (which is the cleanest way i guess)?
Thanks in advance for your reply!
Thanks Ed!
Well, I personally think that the cleanest way would be hiding the custom fields from the post screen and writing so-called metaboxes to fill it up with functionality, which at the back would actually use custom fields to store the data. What about you?
Same opinion! :D
So I tried using the workaround given by Spencer at http://wefunction.com/2009/10/revisited-creating-….
It did only work for one custom post type. I ran into troubles while trying to make different metaboxes for different post types. Did you manage to get this to work and if so, would you be so kind to show me the code?
Thanks!
Sure Ed, this is how you add a meta box to the custom post type called "property": <code>add_meta_box("my-id", "Title", "func", "property", "side", "low")</code> where func is your callback function which displays the text inside the box.
Hope that helps. (worksforme ;)
wow, amazing! I've been using Wp and Tumblr side by side for some time, this would open up a whole new field for theme developers (& plugin devs too). Can't wait for all the cool stuff!
Great write up! Thanks!
Hi Kovshenin
Thanks for this it's really helps getting started :)
However it works in the admin screen (I can see, edit and create podcast entries) but when I got to view them on the actual site I just get a 404 error. I'm using a fresh WP3.0alpha install for testing so there shouldn't be any conflicts from plugins, modifications etc.
Can you think of any reason an entry would be created fine but not show on the actual site?
Ryan, you might want to turn _builtin to false and add a rewrite slug. Discussed in more detail in my upcoming blog post ;)
GREAT improvements! It's just what i needed for certain project types.
Keep up the gook work guys!
GREAT!
We make custom portfolio themes and this will make life so much easier for users! Being able to create a separate post section for galleries is a great idea.
Bring on 3.0!!!
Or you could just learn Drupal.
Check out CCK which lets you create custom content types (posts in the WordPress world) and add custom fields of all sorts to individual content types.
Then check out Views which lets you create filtered pages and blocks of content based on content types and values in individual content fields. Views Slideshow is an awesome extension of Views that's worth looking at too.
I know ….. there are some pretty good reasons why most of you are using WordPress rather than Drupal. But given the excitement this post has generated, it's at least worth a look at how Drupal already does this …. ?
David
But what Drupal gains in powerful features it loses (massively in my opinion) on simplicity and usability, especially for the end user. I have worked in both, and prefer WordPress, even though in some cases it's harder to setup, requiring 10 minutes of thoughtful code rather than an hour setting up a CCK type.
Definitely will, although there's something I don't like about Drupal. I don't know what.
Sounds great, though I tried and not understood about the columns you create in the admin panel for editing, where are these fields of "length", "speakers" etc inside the post type editing itself? should these be custom fields ? where they are being defined?
Maor, in my example above they're not being defined anywhere, it's just something I wrote to get an example of the UI.
When actually dealing with such stuff, yeah, you'd probably use the post meta (aka custom fields) to store such data and display it in columns in the my_custom_columns function.
Has anyone checked out the CMS Press plugin: http://vocecommunications.com/services/web-develo… ? It seems to close the [UI] gap on custom post types in WP 2.9. Feedback?
Hey Jason, looks good, as a user interface to adding and managing custom post types. But why would you need such an interface? If you're a theme or plugin developer you'd rather deal with 10 lines of code than the GUI. If you're not a theme or plugin developer, why would you add custom post types in the first place if you've no idea how to use them?
I've seen this question somewhere in the WordPress Trac, they asked for a GUI to manage custom post types within the core. Ticket was closed and marked as invalid.
As something to temporarily fix the gap, perhaps, though personally, I'd rather wait for 3.0 ;)
Cheers!
[…] in WordPress 3.0 ! Mar.26, 2010 in All, Technology, Web work, WordPress The rumour has it that WordPress 3.0 will have custom post types built-in. These are excellent news! This means that 90% of all web development companies will […]
Looking really good
Do you know if Custom Post types are searchable?
Of course they are, maybe not the standard way, but via WP_Query no problemo! ;)
Just ran a check. Custom post types are searchable just like all other content, via the "s" query variable. Good to know there's no extra work involved for doing that!
[…] Custom Post Types in WordPress 3.0 Some more exeplanation about the custom post types in WordPress 3.0. Anothe great feature that will boost the CMS capabilities of WordPress! (tags: 3.0 development wordpress) […]
That looks great!
Now the great think would be to be able to combine these custom columns with taxonomies, and display the content of taxonomies in that view. I will look into it, because it looks promising!
Right Jeremy. It's fairly simple to do that as the $post global is available during customizing columns. You could basically squeeze any kind of information there, as well as custom fields and post attachments, such as images.
Not that simple for me unluckily. I have been trying, I do not find how to display the taxonomy content :(
Could wou help me with that? I guess it would be something like $taxonomies->taxonomy_content, but I don't really know…
Assuming you're in the my_custom_columns function, get the post contents using <code>global $post;</code> then use something like <code>$terms = get_the_terms($post->ID, "location");</code> to get the location taxonomies for the current post.
I actually wrapped that up in a function called get_the_location() which belongs to my class, then I call $this->get_the_location() which gives me an array of the terms together with their links, so I simply implode() and echo.
Of course you may want to output different taxonomy than location, it's just that I'm working on this real estate thing..
Good luck!
Well, these custom post types features probably will be the biggest new thing in WordPress 3.0.when it comes out. I'll probably use them for adding different media and write/publish articles in a couple of languages. Thanks for explaining. Secondly maybe the multiple domains on one installation, which I am not familiar with as yet.
Multiple domains? Are you sure you want to run a single database for multiple blogs? I'd rather run seperate databases under one installation to share the static content, themes, plugins, etc, but definitely not the database.
I wrote about this last year with a few experiments, it's as simple as determining the domain in wp-config.php and then setting the correct database settings.
Thank you Konstantin. Yes I agree with you, or better to say thanks for your opinion and help on the "separate databases under one installation to share the static content, themes, plugins, etc, but definitely not the database". I will find your page on the "determining the domain in wp-config.php and then setting the correct database settings", to learn somethings new for the wp version 3.
Here's the post: Multiple Sites Driven By One WordPress Installation
Cheers!
Great writeup of this new feature. I'm looking forward to playing around with it. We'll probably use it to create custom posts for the following:
Testimonials
Press
Events
Another step in the right direction for wordpress. Thanks again.
Jesse
Good idea Jesse, yeah that's a big step forward for WordPress being used as a CMS rather than a blog platform. Products, Clients.. We could even organize a CRM inside making certain post types private. The possibilities are endless!
is it ok with wp2.9.2 ?
Not quite. I believe the core support custom post types, but there's no functionality to display the extra edit post screen in the admin panel, plus some bugs are being fixed in 3.0, taxonomy, etc.
[…] sjajnom opisu novih mogućnosti verzije 3., korisnici WordPressa biće u mogućnosti da korite neke predefinisane tipove zapisa, […]
Are the custom posts by default in the same feed? Can you have separate feeds in 3.0, like you can in Expression Engine? The custom post types in EE go along with a custom feed. So you could have a portfolio post template that is tied to the portfolio, and an articles post template for the articles feed, etc.
Douglas, I believe they go separately, as by default WP_Query assumes that post_type is set to "any" which means "post", "page" or "attachment". Maybe that'll be changed in the future to support custom post types, but until then you'll have to explicitly state post_type=yourtype in order to get the content.
That area is being played with every day though, I filed a ticket myself today about custom post types and taxonomy. It is a 3.0 feature though and it's still in the alpha stage, so I guess we should give the guys some time to wrap things up ;)
Anyways, about the feeds, you're always free to play with WP_Rewrite and define your own rules for printing RSS content, i.e. direct posts to:
<code>index.php?post_type=yours&feed=rss</code>
I guess.. ;) Cheers!
[…] WordPress, Matt Mullenweg’s blog today, I came across this link to an article detailing the new custom post types that will be in WordPress 3.0. For a geek like me this is very exciting stuff and will exponentially increase the amount of cool […]
I have been using a lot of custom fields in the past six months to bring databases online through wordpress. Many years ago I used Drupal and found that the data was locked to what drupal developers consider a plugin but most users considered a main feature the CCK. It got to a point a few years ago were there were some serious security improvements in a new release and the CCK was not being updated for months so I exported my sites bit the bullet and moved to WordPress…
Now I am at the point where my sites are deployed in WordPress and it seems the codebase is going through another radical change.
I seriously hope that any transition away from Custom Fields won't happen like the decision to remove ID's from the dashboard…. in the dark of the night with no notice to end users.
When Development time is equal to or larger then the time spent actually making content this is where the line is drawn for most users…
I have a bad feeling the 3.0 codebase is going to be a real serious step for all of us to adjust to.. some people won't want to continue if the redeployment time is equal to a transition to a different platform even if that means a end user designed platform.
I have considered many times why I even take that next step from grabbing a CSV MDB or XML Database … dumping it into MySQL and then preparing it for importation to WordPress.. why not just keep it in the database and write my own code to allow new posts…
The reason is extendability.. well that is the reason now.. but then again I have that decision do I need to use a Sociable or GoogleMaps or Akismet plugin so bad that I am willing to go through not only importation … but a transition that will take more time to process … then the time I spend making content..
This is a serious consideration MATT needs to decide.
Hopefully since I have not been downloading beta it will be smooth
If not then everyone who isnt a 16yo girl running a hello kitty / Hanna Montana site will need to decide which direction they move…
Fine Grain Control vs dumping it all in the_content..
We will see.
[…] Custom Post Types in WordPress 3.0 (tags: wordpress development programming custom post) Bookmarkealo […]
It's important to note that custom post types are not equivalent to custom post flavors, and if you use them that way, you're going to be disappointed. It's best to think of them as custom content types. Some better examples:
– Products
– Events
– Albums
Custom content types are not going to be in your main feed, a very important caveat. We're working on ideas for custom post flavors, which would be more of the "video post" vs "audiocast post" variety.
Good point there Mark, though with a little bit of coding magic you could get a mix of your ordinary and custom posts on any page at any time ;) you could even stick pages to them, show attachments and links. Oh yeah, that's what I call flexibility! Viva WordPress ;)
Mark, thanks for pointing this out. While this article doesn't cover the "supports" parameter, I'm glad that is an option to easily add capabilities such as excerpts, comments, etc. It even lets you specify whether the custom post type appears in searches. However, I'd like to see a couple of extra parameters added:
1. Display in blog – Allow us to specify whether or not these custom post types appear in the standard blog pages
2. Display in RSS – Allow us to specify whether or not these custom post types appear in the standard RSS/Atom feeds. If turned off, then have its OWN feed separate from the main feed. i.e. we'd have RSS Feed, Comments Feed, and whatever Custom Post Type Feed.
I've been thinking of writing a forum plugin that uses custom post types, so that the code could be dead-simple, using all the built-in WP capabilities, with the data stored in the standard posts file for easy export/import, etc. It would be great, though, to be able to choose to include forum posts on the home page/index pages and/or in the standard RSS feed or not.
Other uses of custom post types, especially the "video post" and "podcast" type posts, would definitely make perfect sense to include in home/index pages and in the standard RSS feed. With the above suggested parameters, both use cases could be handled.
Great addition Tim!
I use a plugin called Magic Fields that seems to offer what you are describing. I use it for a pet shelter site so people at the shelter can create posts for cats and dogs. They pull up a new post in the cat section and it asks for breed, age, declawed, good with kids, photo, etc. It is a great way for making sure that the users at the shelter include all the data needed for a pet listing.
If that is what you are describing here that would be great to have directly in WordPress, although shout out to Magic Fields because it has worked very well.
Magic Fields, More Fields, yeah there are tonnes of plugins that do that, and as mentioned above there are some that fill the gap between 2.9 and 3.0, as the register_post_type was introduced in 2.9, but without the interface ability which is set for 3.0 ;) But if you're okay with such plugins for particular cases then you shouldn't worry. But when you'd require more customization, implementation into the theme, etc, etc, then you'll be better off with core functionality.
[…] Weekly Round Up: Issue 2 March 30, 2010 — Jason Ashdown WordPress introduces custom post types in version 3.0 https://konstantin.blog/archives/custom-post-types-in-wordpress-3-0/ […]
[…] Custom Post Types in WordPress 3.0 — Wordpress 3.0 wird zu Tumblr — irgendwie. […]
Great post Konstantin, thanks for showing so great examples. This feature would be useful for me.
You're welcome George ;)
is there some easy way to move the custom post types in menu? I want them prior the posts etc.
I wouldn't call this easy, but here's a way without patching WordPress:
<code>add_action("in_admin_header", "my_menu");
function my_menu() { global $menu; print_r($menu); }</code>
This will give you an array of all menus which at this stage may be changed or shuffled.. I guess there should be a filter somewhere where $menu could be changed in a more usable way. You should look for it in the sources. Hints are admin-header.php, menu-header.php.
Cheers!
[…] Custom Post Types in WordPress 3.0 by Konstantin Kovshenin […]
This is a great tool for my blog. Thanks for the easy to follow Custom Post tutorial.
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] هذا الدرس واستخدمته لبساطته ومرونته وتم عمل اللازم بنجاح بكل […]
[…] feature with this release of WordPress. Here is what Konstantin says about this feature in a blog post Why would we want to play around with custom fields, or add stupid meta boxes in the Edit Posts […]
[…] noch nicht alle neuen Features, aber das neue Standadtheme “Twenty Ten”, die “Custom Post Types” und die “Multiblog-Funktion”, die aus der Zusammenführung von WordPress und […]
[…] V značnej miere bolo zdokonalené vytváranie a správa takzvaného ”Custom Post Type”, teda ďalšieho druhu príspevkov ako sú teraz napríklad články, stránky, odkazy, prílohy… Ak vás táto funkcionalita zaujala, alebo ste už dlho na takéto niečo vo WordPresse čakali, tak určite neprehliadnite článok, ktorý stručne opisuje ako s “Vlastnými Typmi Príspevkov” zaobchádzať. […]
[…] […]
Hi,
nice post! Really good summary on the feature!
Tiny thing that you should probably change: In your code for register_post_type() you are using the "_builtin" and "_edit_link" parameters, although they are for internal use only (you probably have them in there, because you copied the code from the "post" and "page" post types). Especially setting "_builtin" to true could lead to problems in future version, so I recommend removing both of those parameters from your function call.
"_builtin" will then be set to false and the "_edit_link" to the same as now.
Best wishes,
Tobias
You're right, I did copy the code from post/page registration and they do cause problems when querying, I explained this issue in the follow-up post. Anyways, removed them from this posts' code, thanks for pointing it out.
[…] 自定义文章类型功能已经加强,可以很 容易的就添加新类型,所以做做看,它是什么样子的。 […]
[…] Pour en savoir plus, rien ne vaut quelques images et une méthode de test accessibles sur kovshenin. […]
[…] 自定义文章类型功能已经加强,可以很容易的就添加新类型,所以做做看,它是什么样子的。 […]
[…] Custom Post Types in WordPress 3.0 […]
great, i want to try this WP 3.0, i hope this more powerpull
Definitely a great addition to WP and from how it's explained it seems like it will be quick and easy to use also. Great work and I'm looking forward to this!
Thanks for great explanation.
Sidenote: I think with your comments-array, you have "," too much at the end.
I use extra commas in such arrays as I constantly add and remove stuff. PHP is fine with extra commas but causes errors when lacking ;) Corrected the code, thanks!
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] totally new and can see myself using often. The ability to register new media specific aka, “Post Type” menu items. By adding some code to functions.php (or custom_functions.php in Thesis) you can […]
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] 自定义文章类型功能已经加强,可以很容易的就添加新类型,所以做做看,它是什么样子的。 […]
I think this is actually a much more intelligent way to approach things. Anyone who has wrestled with a client trying to use a complicated theme (studiopress.com anyone) will know that keeping the options on the add post/page pages makes sense and keeps support at a manageable level.
I have had phonecalls with clients that have left me wanting to throw my laptop out the window so keeping it simple works out really well for me.
Disclaimer: not all clients are hopeless, just most of them. ;o)
Right, some of them also dislike WordPress' built-in admin system so they ask you to build custom ones, with the layout they describe ;) they're called Clients from Hell haha
[…] https://konstantin.blog/archives/custom-post-types-in-wordpress-3-0/ […]
[…] năng Custom Post Type đã được cải tiến. Nó thực sự dễ dàng để thêm các kiểu mới, hãy thử làm điều đó xem […]
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] Aber liest selbst über die neue Funkionen! […]
It all sounds great doesn't it! I found this Custom Post Type UI Plugin a couple of days ago, this looks a fantastic way to add the Custom Post types without the need to code. Have a look at http://wordpress.org/extend/plugins/custom-post-t…
Rob, right, yet another custom post types 2.9 gap-fixing plugin ;) bot no more worries, 3.0 has almost arrived ;)
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] 自定义文章类型功能已经加强,可以很容易的就添加新类型,所以做做看,它是什么样子的。 […]
[…] the GUI. (Or that I am an idiot who just overlooked it.) Regardless, web developer Konstantin has a great preview of the current custom post functionality, which must be implemented at the PHP code […]
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] Bon, c’est un peu le point le plus épineux à comprendre, et donc à expliquer, mais WordPress 3.0 vous donnera la possibilité de créer plusieurs types d’articles. D’un côté, donc, on aura les billets traditionnels du blog et on pourra ajouter à côté des templates plus spécifiques en fonction de vos rubriques pour présenter un catalogue, des podcasts ou plein d’autres choses. Si vous avez envie d’en savoir plus et que vous n’êtes pas réfractaire à l’anglais, je vous propose de lire cet excellent article sur le sujet. […]
[…] la funcionalidad de tipo Post ha sido reforzado. Es un proceso más sencillo para agregar nuevos tipos, así que hacer eso y ver cómo se […]
[…] Custom Post Types – This is a pivitol addition to WordPress CMS capabilities. Check out a great article about what you can do with custom post types. […]
[…] are not just blog posts but videos, podcasts, etc. Now WP can manage those specially if necessary. Here’s a post where you can learn more about this.New Default Theme Not a huge deal, but the new default theme […]
So, it's a CMS. Yay. Already solved that problem a decade ago. Ah well, this will make it a more viable alternative to more complicated solutions for simple sites. Better late than never. That is, if they make a GUI for it.
CMS? Meh that's old school. I like to call WordPress a Framework ;)
[…] Also a nice feature I found while looking around a bit that may come in handy for a lot of people is this: Custom Post Types. […]
[…] vos billets par types de publications. Voilà une idée intéressante, la fonctionnalité «custom post types» permettra d’organiser […]
[…] custom background and header options.Custom Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it looks!WordPress MU users should test the multiple sites […]
[…] de tipo Post. Es un proceso sencillo para agregar nuevos […]
[…] dessa ideia é o fato de uma das novidades previstas da versão 3.0 ser a função “posts personalizados“, que classificará os posts por tipo de mídia – podcast, citações, vídeos, chat […]
[…] 自定义文章类型功能已经加强,可以很容易的就添加新类型,所以做做看,它是什么样子的。 […]
[…] Custom Post Types in WordPress 3.0 […]
[…] Might be a little late for this one, but the WordPress 3.0 beta incliudes custom post types: Custom Post Types in WordPress 3.0 Extending Custom Post Types in WordPress 3.0 First Impressions of Custom Post Type – label, […]
[…] oficial e instalarla como de costumbre, y empezar a experimentar las nuevas funciones como los tipos de posts personalizados o el nuevo tema por […]
[…] Custom Post Types – This is a pivitol addition to WordPress CMS capabilities. Check out a great article about what you can do with custom post types. […]
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] Custom Post Types in WordPress 3.0 […]
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
Will there be a blocks feature like in Drupal?
And also, will the word "blog" be removed from the dashboard?
You have a new function in 3.0 which called get_template_part()
http://codex.wordpress.org/Function_Reference/get…
[…] 自定义文章类型功能已经加强,可以很容易的就添加新类型,所以做做看,它是什么样子的。 […]
[…] new post type feature was previewed last month by Konstantin. This new feature allows will allow you to set posts as a certain type such as video, podcast or […]
I like this idea a lot. Currently I struggle to get clients to understand the difference between a post and a page, let alone figure out how to create special types of post. I hope this puts an end to all that messing around with custom fields and categories then having to explain it all to clients.
XML-RPC and custom standalone admin systems will help your clients ;)
Very timely for a site Ive just started working on..
Events is my custom type :)
[…] カスタム投稿タイプ機能が強化されています。新しい投稿タイプを追加するのはとても簡単ですので、実際にやってみて、どんなふうになるかチェックしてください ! […]
Why no graphical interface? Is this in the works?
What to say about this feature? AWESOME!
For so long, I was searching a way to customize my wordpress instalations to fit almost everything I wanted, but was too complicated… needed to wrote a plugin and create a new database table, etc… now is just WOW: A true-friendly-very-customizable Framework!
Graphical Interface? Perhaps the next step?
Why would you need a graphical interface? It's all up to the theme developer, isn't it?
OK, I kind of get it but where would I put this code exactly?
I tried looking through all the other comments but they weren't loading for me.
This code as you can see it is not meant for a plugin.
Where else? Good guess. In your template's functions.php file.
I tried it on the default theme for wordpress 3.0 and on checking my dashboard on the left menu I did have podcasts.
Wow! I never thought it could get that easy . Thanks Kovshenin!
[…] Source: Kovshenin.com […]
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
With WordPress 3.0 is it possible to post some differents articles :
For example for a hardware / high tech webzine :
– (classic) post for news / actualities
– articles for reviews, guides, etc..
If yes, how it's work in the database ? Is is in differents DB tables ?
Thanks in advance ;)
NOt really? The different articles are on the same table in the database their meta fields are the only ones that are different.
If you check the posts table you will find all the articles. The field 'post_type' is what specifies what type of post it is. For the classic post it is simply 'post' for pages it is 'page' and other custom post types appear as specified.
Hope this helps ;)
Thank you for your quick answer ;)
Here you go: http://codex.wordpress.org/Database_Description
[…] about is the new network feature that is a result of the development team merging MU into the core, custom post types (this will make things so much easier in the future, although porting my custom fields and the like […]
I would love how to configure Radio Buttons using this example!
Excuse me?
[…] あと、Custom Post Types が、3.0の新機能。 […]
[…] https://konstantin.blog/archives/custom-post-types-in-wordpress-3-0/ […]
[…] make things easier for WordPress consultants to customize the websites easily. Learn more about Custom Post Types in WordPress 3.0 over here.Focus on Themes – New theme “Twenty Ten” will be the only default theme in […]
[…] […]
[…] […]
[…] do so far is install it, but I’m looking forward very much to playing with the new features, custom post templates and menus […]
[…] post types : It’s really easy to add new […]
Is there an easy way to link the different post types together.
I know it is possible to do "Taxonomies" to a post type but I want link them together in the same way tags would work. Say I create a post type called "Cars." Here I create various car models. Then I create a post type called "Reviews" and use the standard post type as "News." Is it possible to add car models to these two post types as you would tags? So when I'm looking at a "Porsche 911" cars post I can see all the related "reviews" and "news" posts?
Hope it makes sense!
It does.. And it's called theme magic ;) You could run a WP_Query to look for the same post but of a different post_type and fire the loop from there.
Спасибо за пост. Только что попробовал эту фичу вместе с multisite на localhost, – все работает "на ура". Подтягивается ВП к Друпалу :)
;) точно
[…] be something you can do with new WP 3.0 custom post feature – have a look at the […]
This is the best decision Automattic has made with this software in years. I for one, am excited about this. Currently, I've been using Flutter for this purpose, but I have been having the hack the life out of it to keep the number of DB queries with in a reasonable limit.
Thanks for this. Interesting to see what possibilities are possible with custom post types. Can't wait to try it out and see how much time and effort it saves.
[…] The Custom Post Type feature will make it possible to have a certain type of post show up with only those features that you really need when writing a post. Cutom Post type Configuration […]
[…] it would be nice to be able to simplify the creation of additional post types (you add them via actions in your themes functions.php file as default). And we’ve also simplified the way to manage user roles and their capababilities […]
Custom COlumns as well?
AWESOME! Thanks for the code, that was a very good post
Custom columns were there long before the custom posts UI, but anyways, you're welcome ;)
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
Excellent article Konstantin, it inspired me to try it out for myself. I was able to fill my columns using input for custom fields If you get a chance, check it out. Thanks for teaching me something new!
http://www.heinencreative.com/archives/tutorials/…
Hi Chris! Thank you for this — I was struggling to figure out how to pull the custom fields — this solved it!
[…] excellent account of custom post types is provided by Konstantin Kovshenin. He makes the point that custom post types are about […]
[…] di sfondo – Cambiare username e password – Tipi di messaggi personalizzati; è abbastanza facile aggiungerne nuovi tipi – Facile gestione di più blog da un’unico Pannello di controllo, […]
What should I do to show blog custom post types from users on my network (MU)?
Good question. Anyone? ;)
Thanks for the good article!
I've a question: the above "my_podcast_columns" works ok when in "register_post_type" I set "hierarchical" as FALSE, but it does not when set as TRUE. Why?
Fantastic! For those who want to have thumbnails display in the edit columns for a custom post type, check out WP-Engineer's post on the topic for non-custom post types. Combining that with your efforts was a snap and looks fantastic.
Just trying to find out a way to – for specific data types – retitle "Featured Image" to be meaningful for the data type (i.e. Podcast Image, CD Cover Art, Main Property Image, etc)
[…] Custom Post Types in WordPress 3.0 […]
How to create more itens below "Add New" ?
[…] Custom Post Types in WordPress 3.0 […]
[…] Kovshenin – Custom Post Types in WordPress 3.0 […]
[…] Für Fortgeschrittene und Perfektionisten kann man im Backend auch die Darstellung der Spalten noch weiter anpassen. Ein extremes Beispiel mit guten Erläuterungen findet man bei Konstantin. […]
[…] 自定义文章类型功能已经加强,可以很容易的就添加新类型,所以做做看,它是什么样子的。 […]
Would you (or someone reading this) mind helping me out in explaining how an additional filter option can be added to the admin post list screen based of hard coded meta key variables/taxonomies or automatically listed based off meta key/taxonomy values?
I am also looking for a way to be able to "sort" the columns up/down and set a default column to sort the edit post results by.
I feel this is very important to be able to utilize these custom post types correctly and effectively for clients.
Thank you Konstantin! – great post and tips :) after seeing this, I'm looking forward to what we can do with WordPress 3.0!
To echo binarypixel above, is there a way to sort the posts by any of the columns?
You're welcome. Sort order, yeah, all you have to do is hook to the posts_orderby filter when selecting them and write your custom SQL. I managed to make the column headings clickable so that you could pick ones to sort by. Just make sure you filter when is_admin() otherwise you can mess up the order in your theme.
Would you be so kind and please provide the script your using?
It really depends on your needs, which fields you'd like to use to order, how to order them etc. Just Google the posts_orderby hook or read it in the sources. It's simply a way to inject your stuff into SQL.
Fantastic work! I'm thrilled about the prospect of soon using 3.0.
One question… I couldn't help but notice that in the second image of this post, your "Speakers" were not alphabetized!!! "Joel Spolsky" followed by "Jeff Atwood".
I checked out the code, and you register the variable "speakers" with the following:
register_taxonomy("speaker", array("podcast"), array("hierarchical" => true, "label" => "Speakers", "singular_label" => "Speaker", "rewrite" => true));
and then you echo it with the following:
case "p30_speakers":
$speakers = get_the_terms(0, "speaker");
$speakers_html = array();
foreach ($speakers as $speaker)
array_push($speakers_html, '<a>slug, "speaker") . '">' . $speaker->name . '');
echo implode($speakers_html, ", ");
break;
I have been pulling my hair out looking for a way to list authors (or any variable) in the order they were inputted per post. For example, Joel Spolsky would be listed first on one post, but he could be listed second on other posts. Does this method achieve that?
I'm not sure.. It's taxonomy after all.. Meta data, which shouldn't have an order. You might want to go with custom fields instead.
Nice post :D
I am so excited to get going on my new project – it is going to make the site so user freindly!
Thanks again for the great post
You're welcome ;)
GREAT!
What about has_one, has_many and other complicated but funny relationships we can get our data in?
I love to play around with this feature. Though I'm afraid (but happy) WordPress will lose her Word Press core usage ;-).
I expect one of the next-most-used types will be "Products" in 2012 …
2012? I'll bet you for 2010-2011 ;)
[…] Custom Post Types in WordPress 3.0 […]
Great post but I have a question!
I've created custom post types and I have pages where you see all posts of the specified type and the single post. Is it possible to have a custom post type category listing page?
I have /custom-post-type/ working fine, that lists all posts of that custom post type.
I have /custom-post-type/post-name working fine, that shows a single post within the custom post type.
I want /custom-post-type/category/ where you can see all the custom posts within the specified category, is this possible?
Thanks!
Sure, create a post called category and give it a custom post template, in which you're free to do any php coding you like ;) P.S. Post templates are not a WordPress standard. WordPress has only page templates, but google for a way to implement it into posts.
i have thousands of pages with 5 top levels. can i separate each level as a new post type?
Why d'you ask? I don't see a problem here.
[…] Una de las funcionalidades más esperadas de WordPress 3.0 (ya se puede probar la beta 1 de esta nueva versión) es su capacidad multidominio. Otra es la de poder tener tipos de posts personalizados. […]
I'm intrigued by that custom post category question as well. You'd think you'd be able to just put "category" into the "supports" array of the register_post_type array, but it don't work. Hmmm.. Anyone any ideas about this? It would be pretty handy.
It's taxonomies isn't it… of course it is.
Right, and it took you 7 minutes to figure out ;)
What custom post types am I going to add??? Files, files, files and turn WordPress into some kind of version control CMS for software hosting.
Files? Yeah, you could pretty much implement a file versioning system like in Basecamp by 37signals, but I doubt that you'll reach Subversion or Git level with WordPress, there's too much parsing to do. You'll be better off implementing Svn/Git into WordPress :-P
Actually I'm looking for a middle ground here. If someone wants specialized version control there are already tools for that. However for something basic like starting a software directory this may come handy. Git/SVN into wordpress? I'm all ears…any pointers to get started?
Well, take a look at Trac ;) I'm looking for something similar, but more of a CRM and/or project management tool, sort of like Basecamp maybe, but the source control in Trac is simply awesome, and awesomely tied to Subversion!
[…] One potential application for this would be podcasts – so rather than adding a podcast as a post or using a plugin it could be managed by the custom post type. There is of course the option for custom taxonomy’s. If you don’t want to use a plugin and your familiar with the editing wordpress functions file here’s a Custom Post Type tutorial. […]
[…] 自定义文章类型功能已经加强,可以很容易的就添加新类型,所以做做看,它是什么样子的。 […]
[…] a fim de variar a cara das publicações, mais ou menos como o Tumblr trabalha por padrão. (Mais informações, em […]
[…] Kovshenin […]
[…] Custom Post Types in WordPress 3.0 […]
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
This works great I had to add 'title', 'editor', 'author', to the array to get a normal looking post.
I'm running WP 3.0 Beta 2 and I can't see the Featured Thumbnail feature with a custom post type. I have included the 'post-thumbnails', in my array.
I can see it fine when I create a regular post.
I was wondering if anyone else had this issue a solution.
Found it! it's 'thumbnail', not 'post-thumbnails', so awesome. Thanks for this great post.
Right ;) You're welcome John!
Short snapper because I really haven't spidered this functionality yet … maybe I'm way off base.
My idea is this (with a long-shelved project in mind): re-entrant material.
I.e. I "comment" on blog post A, but that comment itself becomes a post.
When I look at post A, I see what appear to be normal comments. But some of those comments are special: clicking on them doesn't reveal just a nested tree of replies but, rather, presents that material as a stand-alone post.
I bring it up now because I think Post Types can pull this off … maybe combined with Custom Taxonomy.
cheers
I guess it's what comment meta is for, but you can always restructure the whole commenting and use post_parent to indicate posts which are comments, maybe custom post types could help, yeah but I'm not sure about selecting. Let us know when you figure it out ;)
Sorry I missed your reply @kovshenin … always makes me shudder when email notification slips past; no telling the consequences!
It might be doable through meta, but I suspect … meh don't want to hex myself into extra complexity right off the bat. (This is long-term / deep background for me; "ASAP" but no rush. *G*)
Experiments and test cases will show you whether you're right or wrong
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] funcionalidade Post Tipo foi reforçada. É realmente fácil de adicionar novos tipos, para fazer isso e ver como […]
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] a fim de variar a cara das publicações, mais ou menos como o Tumblr trabalha por padrão. (Mais informações, em inglês). Custom post […]
[…] カスタム投稿タイプ機能が強化されています。新しい投稿タイプを追加するのはとても簡単ですので、実際にやってみて、どんなふうになるかチェックしてください ! […]
[…] gaat heeft een van WordPress’ core-developers een technisch verklarende tutorial overgeschreven: “Custom Post Types in WordPress 3.0”. En bekijk WordPress’ Codex voor functies register_post_type & […]
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] 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 […]
[…] a fim de variar a cara das publicações, mais ou menos como o Tumblr trabalha por padrão. (Mais informações, em […]
[…] to the wait for WordPress 3.0. and Custom Post Types. Till then, Flutter […]
[…] focuses on how you can have a custom display for certain content, support custom URL structures or manage content differently. These things aren’t new – they are all things you could do previously without too much […]
[…] Guide to WordPress 3.0 Awesome New Features10 Features to Look Forward to in WordPress 3.0Custom Post Types in WordPress 3.0WordPress 3.0: Ultimate Guide to New FeaturesDisplay Comment Form With Ease In WordPress […]
Hi Konstantin I'm sitting down to do a project for a client's site needing a Real Estate section. What you have in your screenshot is exactly what I had in mind. I'd rather not reinvent the wheel, so to speak, if we could work out an arrangement. Could you please contact me at either my e-mail or DM me on Twitter. Thanks, and great info on custom post types!
Lindy, the real estate module is a commercial project that's being done within our company. I'll pass on your contact details to our sales team and you could talk it over with them. Hope that's fine with you.
Thanks
[…] required in larger projects – XML-RPC. It’s not limited to WordPress 3.0, but as custom post types are on their way in 3.0, we’ll probably see tonnes of new ways WordPress being used. […]
[…] de dire que c’est à la fois très simple et rapidement très puissant comme le montre ce tutorial. Cette fonctionnalité va grandement faciliter la vie des développeurs qui pourront éviter la […]
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] 2 En till artikel om Custom Post […]
If our understanding is correct, custom post types are primarily going to be set up and managed in functions.php – ie, a theme file. This seems totally wrong: these post type definitions don't belong to a site's theme, they should be part of its underlying structure. Custom post-type definitions (and likewise custom taxonomies) ought to be theme-independent, allowing the user to change theme but maintain the site's content and hierarchy.
Moreover: isn't it wasteful to have these definitions in PHP code in a file which executes repeatedly and redundantly every time a front-end page request is made?
One more potential drawback of this method: if you edited functions.php to change the post_type definitions once a site was already populated with data, couldn't you quickly lose touch with the contents of the underlying database, with no way of cleaning it up or getting back to your previous state?
In our view these features should be configurable either through a GUI in the WordPress admin, or through YAML (or similar) but away from anything to do with the theme.
This is basically a repost of a comment we made on WP-Engineer (http://wpengineer.com/impressions-of-custom-post-type/#comment-4400), so sorry for the repetition, but it seems like an important enough issue to raise here as well to see what people think. We're also rooting through trac to see if our doubts have been raised (and countered) there.
Any comments? Have we missed something?
Initiate them through a plugin. Then you can swap themes to your heart's content. As for editing definitions after the site's gone live; you're quite right, there'd be lots of homeless data in the database and it would be a fiddle to clear it up. Once you've defined your post types and custom meta, best not to alter it – and actually, I don't see why you'd ever want / need to either.
it's just that every site we've come across so far, from nettuts to wpengineer to wp itself, talks about or recommends using functions.php to register the custom post types… and most also say, or imply, "plug-in = bad; core = good" which would suggest that this new (big) functionality ought really to be a new part of wp-admin, no?
sorry – I expressed myself badly… what I meant by "most say plugins = bad, core = good" was something more like this:
commenters on articles about WP3.0's "custom post types" often say that such-and-such plug-in already allowed you to extend WP in similar ways. The response to those commenters is usually along the lines of: "but this is core, so it will be inherently better documented and supported". That would imply that the way in which articles and tutorials (which WP.org itself links from its register_post_type reference page: http://codex.wordpress.org/Function_Reference/reg… are currently suggesting custom post types be implemented is better than using plug-ins.
…Which alialib and ourselves feel it might not be, if the potential pitfalls of implementing the post types via functions.php turn out to be real.
Mmmm. yeswework certainly has a point. My functions.php file is chock-full of custom post code that I'd want to keep if I ever swapped themes. But it's also full of style-specific, theme-specific instructions that I wouldn't want to take with me theme to theme.
Perhaps there should be the wherewithal to have a file similar to functions.php, that sits outside the theme architecture, maybe accessible in an editor similar to the theme editor in WP. This file could be a global-functions.php, it would initiate custom post types and hold the code to process them once they're in.
At the moment the lines between theme and core are being dangerously blurred. But with most themes now (serious frameworks with child themes) you wouldn't want to change once the site is live. And if you did, the functions.php could be in the parent theme, and you could change child themes as much as you liked without breaking anything.
I think the answer to this really is choose a parent theme framework, and then stick with it.
I create a plugin for that matter.
Even if writing it into a plug-in is safer and more future-proof than using functions.php, if you have to write (or even just install) plug-ins to implement custom post_types, then:
a) you could have done it already with podcms, flutter, et al so the advantages of custom post_types WP3.0 for the average user are reduced.
b) the plug-in (unless it's "canonical" and issued by the WordPress team themselves) is only linked to updates in core WP by the willpower, skill and availability of the plug-in developer, so functionality could break relatively easily (see, for example, the Custom Post Type UI plug-in – it's fantastic, but it's destined to always be one step behind changes to WP3.0 core, so at the time of writing it's partially broken with RC1 under WAMP/XAMPP environments).
basically… you could still very easily lose access to all your custom posts both on your site AND, worst of all, in the admin section of your site.
and I'm sure there are other disadvantages too… we just think that the custom post_type (and custom taxonomy) functionality is important enough to helping WP gain more market share (which Matt said in his recent WordCamp speech) that its set-up and basic management should really be built into wp-admin rather than left to a plug-in or theme file.
@yeswework – I couldn't agree more. I like Custom Post Type UI (or CMS Press) for their approach of bringing the ability to create custom post types back to the average user and hope that within the next couple of releases of WP that type of functionality might make it into core as well. Along with some way to easily share like the repository offers plugins / themes today.
Ignoring the obvious "scope creep in the core" question for the moment, it is an interesting development model where features that are highly sought after can flush out the potential implementation strategies as plugins and then a "best practice" approach get implemented to core. I'd be curious to know in the examples of Tag warrior -> tags, wooThemes menus -> Menu management and the "custom post" plugins you mention, how much of their approach influenced the direction of the core development.
The sunrise.php file might be along the lines of your global-functions.php idea. I've also tried creating an include in wp-config.php to a file in the wp-content directory that contains functions and classes for use in the global scope (probably not the best idea).
[…] Custom Post Types in WordPress 3.0 […]
I think custom post types and custom taxonomies currently posses "features" that should merge in one kind of type.
With these custom taxonomies (and the default ones) we can "tie" custom posts together e.g. tag five of them with "olympics2009".
However "olympics2009" could just as well have a "posting" associated with it as well as some custom fields.
If you would do "register_taxonomy" with a certain custom post type you would get a list of all posts that had been done in that register_taxonomy.
Identical to e.g. having custom post types "contact" and "address". To link contacts with addresses and addresses with contacts you now would have to link them up via a custom field that queries "the other custom post type". If custom post types and taxonomies would be the same kind of object you would not have todo this since they would already carry the properties of being tied to each other.
Then again I might be missing something, just starting up in my wp knowledge.
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] WordPress 3.0 Themes using Custom Post Types Showing custom post types on your home/blog page Custom Post Types in WordPress 3.0 Extending Custom Post Types in WordPress 3.0 Introducing WordPress 3 Custom Taxonomies Artículos […]
[…] le Portfolio. Il y a même un gars qui a fait un IMDB avec WordPress 3…Sources : Nettuts et kovsheninCommenter »tags taxonomy, tutoriel, wordpress, wp3catégorie Astuces, Best Of, Bien […]
any way to get custom post types to tie into Press This tool?
I'm lusted after this for years.
I imagine having a suite of PressThis bookmarklets, each one custom configured with specific settings. Select text, Click, Post!
[…] カスタム投稿タイプ機能が強化されています。新しい投稿タイプを追加するのはとても簡単ですので、実際にやってみて、どんなふうになるかチェックしてください ! […]
[…] posts explained by Kovshenin – Part 1 and Part […]
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] Custom Post Types in WordPress 3.0 […]
[…] Custom Post Types in WordPress 3.0 […]
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
[…] Een korte scan door het menu levert niets op dus gaan we naar Google en komen we op de site van Kovshenin. Wat blijkt, voor Custom Post types moeten er aanpassingen gemaakt worden in functions.php in het […]
Thats ist verry nice i cant wait for the final version. :-)
Anybody on here know if Custom Post Types can be applied retroactively on existing posts? That is, can one do some sort of batch edit on a bunch of older posts and mark them as Custom Post Type XYZ? I'd assume there are many of us who'd like to convert some of our older, normal posts to XYZ to add that additional meta data, but if this only work for posts published *after* upgrading to WP3, when you initialize it in functions for your theme, then that could become a significant road block.
this might work for you – havent used it myself
http://wordpress.org/extend/plugins/post-type-swi…
Niiiiice! Thanks Bob =)
Some SQL magic would work ;)
[…] Custom Post Types in WordPress 3.0 – Kovshenin […]
[…] Custom Posts types in WordPress 3 […]
[…] type to WordPress and you’re away. You can find out more about creating custom post types here. Custom Post […]
Konstantin, I love the simplicity of this plugin, thank you!
One question though, if I want to display a list of speakers from the WP_Query function how would I do that?
I've tried "post_type=podcast" which returns all, but if I wanted to only display posts by speaker "Chris Ross" is there a way to pass something like $recentPosts->query("speaker=Chris Ross")?
If the speaker is a custom taxonomy (which would be the best thing to do, imho) you can simply add it to the query, query_posts( array( 'speaker' => 'chris-ross', 'showposts' => 10 ) );
I'm building a Event Listing plugin, and have a question on this:
How do you redirect to a special template in the event of "post_type=event" and the "query_posts( array…." cases?
Not sure if this completely answers your question but: http://codex.wordpress.org/Template_Hierarchy#Sin…
So you could have a file under your theme called:
single-event.php
And it would handle the display for your event pages.
Yeah, I've found that, but I'm looking for a more direct way of specifying the theme page for a single event & category of events & basic list of events.
I suppose we'll just have to use is_category in the single-event.php page.
Hey, Giovanni has probably answered your question already. Taxonomy and post names have slugs (which contain no spaces, symbols, etc) and they should be used when querying the database, which is why Chriss Ross became chris-ross. That way, you can also combine parameters either in an array (like Giovanni has shown) or in a string: query("speaker=chris-ross&post_type=podcast".
Hope that helps.
[…] ser necessário recorrer a custom fields. Para saber mais sobre esta função recomendo a leitura deste artigo (em […]
[…] recipe posts etc all as explicitly declared separate entities. Here is a blog post that explains custom posts and what you can do with them in more […]
[…] да е вградено от самото начало в инсталацията. Има хубав туториал за това как да се активират. Готиното е, че като […]
[…] https://konstantin.blog/archives/custom-post-types-in-wordpress-3-0/ […]
I do not know why WordPress doesn't add the taxonomy to the admin option instead let people add it manually to the function.php file? Does it slowdown the performance of WordPress?
If they did that, website owners would do all the stuff by themselves, and not hire developers like us to help them out ;)
[…] Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it […]
Hi there,
You say "Perhaps the tricky part would be with the custom columns? Nah:"
I say, YES.
I've made an exact copy/past of your code and if the "Podcast" shows in the Admin, I never see any custom columns.
When trying to add a new podcast, I just can fill the title, author and normal editor :(
Maybe you misunderstood custom columns? They're the ones that appear additionally to your Edit Podcasts (or whatever post type you're working on) screen.
Yes sorry, I was talking about custom textareas & co.
I can just fill a title and classic text editor!
[…] Custom Post Type: lo que nos permite crear diferentes tipos de post, que tendrán distintas plantillas y características. Eso sí, para activar dicha opción es necesario tocar código, tal y como explica este artículo. […]
[…] 自定义文章类型功能已经加强,可以很容易的就添加新类型,所以做做看,它是什么样子的。 […]
[…] Custom Post Types in WordPress 3.0 […]
[…] Custom Post Types in WordPress 3.0 – […]
[…] buenos tutoriales para iniciarse en el tema, aunque todavía les encuentro algunas limitaciones. (Primera Parte y Segunda […]
[…] développeurs, et donc moins de temps à développer. Quelques exemples de dev sont exposés dans cet article et cet autre […]
[…] Custom Post Types in WordPress 3.0 […]
how would you hook into the save post and make a custom field required?
For instance if you have a custom field for price. You'll wanna make sure that its not missed. So you'll want to have it required, and if its empty when the post is added or updated it will throw an error.
Kyle, I think you should visit the WordPress Support Forums for this one, or perhaps their IRC channel. But here's something you might play with – there's a hook called save_post, inside which you can alter the information being saved in the database, as well as add extra custom fields, etc.
Im working with custom post but i have a question, im doing a custom post called "movies" i have something like :
http://localhost/wp3/movies/this-is-a-movie/
http://localhost/wp3/post_type/post
But i like to show all post of a movies
http://localhost/wp3/movies/
http://localhost/wp3/post_type/
But it show 401 Not Found
Apologies, but the page you requested could not be found. Perhaps searching will help.
Any idea?
Jose, I think that it's once again the permalinks question being asked here for quite some time. I still cannot find an easy way around it in 3.0, but I did manage to get things up and running in the beta using WP_Rewrite by adding extra rules to it, and disabling redirect_canonical (in certain cases).
[…] не смутил мой вольный и немного сокращенный перевод оригинала статьи. This entry was posted in News and tagged WordPress 3.0. Bookmark the permalink. Follow any […]
[…] custom post type – Custom Post Types in WordPress 3.0 […]
[…] custom post type – Custom Post Types in WordPress 3.0 […]
[…] out more here […]
Hi,
I know, the following will be a stupid question, but else what can I do? I'm totally a newbie :D
How do I make those menu items of post type appear as in the 1st figure?
Thank you very much!
Heh, never came across such a thing, but you may try the Adminimize plugin, I believe there were some options in customizing the admin menu, perhaps there's sorting too.
[…] ser necessário recorrer a custom fields. Para saber mais sobre esta função recomendo a leitura deste artigo (em […]
First, thanks for the great article. I followed your example for the custom edit columns and I cannot seem to get it to work. The columns get labeled, but no data appears in the columns. Here is that section of my functions.php:
add_filter('manage_edit-listings_columns', 'listing_edit_columns');
add_action('manage_posts_custom_column', 'listing_custom_columns');
function listing_edit_columns($columns){
$columns = array(
'cb' => '',
'title' => 'Listing',
'agent' => 'Agent',
'price' => 'Price',
'status' => 'Status',
);
return $columns;
}
function listing_custom_columns($column){
global $post;
if ('ID' == $column) echo $post->ID;
elseif ('agent' == $column) echo 'agent-name';
elseif ('price' == $column) echo 'money';
elseif ('status' == $column) echo 'status';
}
Am I doing it wrong?
your filter is before your action?
Thanks for the reply Travis; however, that did not change things. I still get labeled columns without any data. I put text in the case clause for testing.
Do you at least get the post id?
hey, I experienced the same problem, is there any ways to make it work? the label was appeared, but the value was not, and… when quick edited the item, the value appeared, but when I refreshed the page, the value disappeared again.
When enabling a custom post-type to be hierarchical: use "manage_pages_custom_column" PAGES not POST
oh hey, that's actually working. thank you. :)
I really want to create a Quotes post type. Can you please provide an example of the code i would use? Also, I am not sure of where I am to place this code in functions.php, any clarification would be helpful.
For the quote I'd want to have the follow fields: Quote (text), Description (text), Team (select category), Person (text)
Thank you in advance for the help,
Jon
Jon, did you figure out where to put it? I'm looking into it right now and nowhere do I find it. Thanks
Look for samples in the Codex, it's quite clear there. Or you may try looking for a plugin what works with custom post types. I believe there was a good one somewhere in the repo.
[…] https://konstantin.blog/archives/custom-post-types-in-wordpress-3-0/ […]
nice post – does this have to be called via add_action(init …. i want to have a form/button to register a post type
[…] Videos, eBooks, etc… and allows you to organize content better. Check out this info on custom post types in WordPress 3.0 and let me know what you […]
[…] you’re on), but can also create something called a Custom Post Type. (Oh god i wish i could explain this really well.) Basically, instead of only being able to create blog posts (which are generally chronologically […]
I would like to try but i'm afraid of upgrading my WP version to the 3.0, everything works for you ?
Works fine, it's all 3.0.1 now ;) so no worries!
[…] funcionalidad de Tipo de post personalizado ha sido reforzada. Es muy fácil añadir nuevos tipos, así que podemos hacer eso y ver cómo se […]
[…] Custom Post Types in WordPress 3.0 […]
[…] A veces, cuando se quiere agregar tipos de posts no estándar de WordPress, puede ser un poco difícil. En primer lugar está la tarea de encontrar una manera de formatear el soporte para integrarse en WordPress y entonces el proceso repetitivo de la adición de este nuevo formato para todos posts que lo requieran, pero esto puede tomar demasiado esfuerzo y tiempo. Aquí es donde el nuevo personal el tipo de posts. Utilizando el API de WordPress, es muy fácil crear nuevos tipos de posts para cualquier tipo de contenido que deseas. Todo lo que necesita es unas pocas líneas de código para definir los detalles de su tipo de post a WordPress y estás fuera. Puedes encontrar más información sobre la creación de tipos personalizados puestos aqui. […]
@tarot i think it's pretty stable to be honest from what i've seen myself – make a backup though of course
is there a way of ordering the rows on the edit list by one of my custom values?
in your example, say order by 'length'
Hmm, good question Sean. I think you can, but no in the text that is echoed to the table. This should be done inside the query, perhaps via some extra JOINs that would grab up some post meta and use it for custom ordering.
[…] vos billets par types de publications. Voilà une idée intéressante, la fonctionnalité «custom post types» permettra d’organiser […]
[…] dessa versão você só precisa de poucas linhas de código – você pode encontrar modelos aqui – para definir um artigo […]
Hi Konstantin. In my page.php i want use a conditionnal tag like is_post_type('podcast') but that doesn't work… what can i do recognize a page which have a custom_post_type 'podacst' ?
i'm not sure if is_post_type() supports the custom post type. But this works:
global $post;
if($post->post_type == 'podcast')
that doesn't work on my site…
but if i use
global $post;
if($post->post_title == ‘title of my post’)
that works…
Strange.
That is strange. Do you think it has to do with how you're declaring the custom post type? Here's my setup:
register_post_type('sales', array(
'label' => __('Sale Items')
,'singular_label' => __('Sale Item')
,'public' => true
,'show_ui' => true
,'capability_type' => 'page'
,'hierarchical' => false
,'rewrite' => true
,'query_var' => false
,'supports' => array('title', 'editor', 'thumbnail')
));
And my template uses:
global $post;
if($post->post_type == 'sales')
Have you done a var_dump on $post var to see exactly what the post type is being set to? That might be helpful.
i have copy your first code in my function.php and the second code in my single.php
but that doesn't work
i don't understand
Ah ha! You can't use the single.php file with a custom post type. Working with the "sales" example, you'll need a file called single-sales.php
Inside that file i simply put a require to my page.php, though you could point it to single.php.
i have create single-sales.php but that don't work
i have change ’capability_type’ => ‘page’ by ’capability_type’ => ‘post’, that doesn't work… :-/
Man, I'm not sure where things are going wrong. At this point I'm out of ideas besides doing var_dumps and manually tracking down where things are going bad. You might want to head over to the wordpress.org Forums and post there (if you haven't already).
is it possible to display the name of the post_type in the single.php (here : sales )?
Hello.
Konstantin, I'm sure you know if it's possible to divide custom fields for custom posts?
I mean I have custom post type "Podcasts". And its item has custom field – "Source".
I want WP not to show this custom field label for another post type (when I add another custom field).
This way it would be possible to use different groups of custom fields for different custom post types.
Ilia, if you need that kind of customization then you'll be okay by simply removing the custom fields block from your edit post screen and use a custom metabox. And it will look cooler too ;)
[…] Custom Post Types in WordPress 3.0 […]
[…] Custom Post Types in WordPress 3.0 […]
[…] אם תשחקו קצת עם הקוד של המערכת, ותעשו ככה ותלחצו ככה. יש מדריך באתר הרשמי שמסביר איך לעשות את זה. אבל אם אתם לא מפתחים, אז זה לא […]
I noticed that your custom columns were kind of faked for this post. How do I pull the info from the new custom inputs i created in the new post type?
Your example pulls the ID but I cannot figure out how to pull say the length (which you simply filled in with 63:50) ?
Michael, take a look at the get_post_custom function in the Codex.
[…] The Edit Property page could even contain a Google Map where you could point out its location!Visit kovshenin.com for more informationThe last, but certainly not the least source I’d like to run by you is […]
Hello!
It is not working for WordPress MU? I need this funcionality.. but when I tried register_post_type function in my function.php it dont work for blogs created in WordPress with Multi-User..
Is there any way how to make it work?
WordPress MU merged into WordPress 3.0.. ;)
[…] Utilizing the WordPress API, it is extremely easy to create new post types for any type of content you wish. All it takes is a few lines of code that define the details of your post type to WordPress and you’re away. You can find out more about creating custom post types here. […]
Hi,
is it possible to set a category at the custom post types automatically?
I use the following as a try:
"add_action('init', 'myfunc_reg');
function myfunc_reg() {
$labels = array(
stuff
);
$args = array(
more stuff,
'taxonomies' => array('category')
);
register_taxonomy_for_object_type('category', 'my_category');
register_post_type( 'specials' , $args );
}"
I want to set the checkbox for "my_category" as true (checked). But I didn't find a solution for it yet…
Can you help me?
Thanks in advance and greetings from Germany,
Fabian
I have the same issue as Fabian. I need to have each post of my custom post type categorized automatically. I'm thinking I may be able to write a little jQuery in the admin to check the box if nothing else. Any advice you can provide would be greatly appreciated.
Hi Niall,
I came to the same conclusion and wrote a small jQuery snippet.
This is my code in the function.php of my template:
function specials_init(){
add_meta_box("credits_meta", "more meta info", "specials_meta", "specials", "normal", "low");
}
function specials_meta() {
… stuff
jQuery(document).ready(function($) {
jQuery("#categorychecklist li").each(function(i,el) {
if(jQuery(this).html().match(/my_category_to_check/)) {
jQuery("input",this).attr('checked','checked');
}
});
});
("my_category_to_check" is a placeholder for your category)
I doesn't like it cause I'd prefer a serverside solution with php/WP but it works for me.
Ah. I forgot the last } to close the function "specials_meta" …
It should be:
function specials_meta() {
… stuff
jQuery(document).ready(function($) {
jQuery(“#categorychecklist li”).each(function(i,el) {
if(jQuery(this).html().match(/my_category_to_check/)) {
jQuery(“input”,this).attr(‘checked’,'checked’);
}
});
});
}
[…] type posts. Yay? Not so much, because you still have to code stuff. Konstantin Kovshenin wrote couple of articles on how to implement custom posts in your WP theme/plugin, so I won’t write about […]
I know it's probably a lot to ask, but it would be amazing if you posted the source for the rental property example you are talking about.
Sometimes the best way to organize is to go low-tech. Ritzenthaler uses old fashioned index cards. He marks each one with the title of a page, then lays them out on a table, rearranging until the flow of the content makes sense.
[…] med WordPress 3.0 och Custom Post Types så hoppar jag nu över denna tröskel som Inläggsfunktionen står för och kan istället direkt […]
[…] Custom Post Types in WordPress 3.0 […]
I am trying to get my custom columns to show, but nothing is being pulled in with my filter. I can get the columns themselves to show with your code, but no data is being inserted. I am wondering if it is because my custom post type has a hyphen in it. Can you fill in data with a hyphen in your custom post type name?
Hi, thanks for this very usefull blog post. I can definitely use this! I've bookmarked your blog
[…] Custom Post Types in WordPress 3.0 […]
Hi Konstantin,
Thank you so much for your explanation on the custom post types.
But I was just trying to make one scenario work which I'm never able to do so.
That is, I would like to create categories using the regular WP sidebar Posts->Categories and assign my custom posts types to them. For eg., I create CAT1 and SUBCAT11 (ie., under CAT1). I then create a custom post and try to assign it to SUBCAT11, which gives me a 404 error, no matter what I try. Do you think you could help me with a hint here? I'm trying to do this in you podcast-30.php file.
Appreciate your help.
Best,
Andy
[…] https://konstantin.blog/archives/custom-post-types-in-wordpress-3-0/ […]
Here is more detailed post I wrote especially for those who want to learn how to show the post thumbnails in the overview columns: http://bit.ly/9Vp89W
[…] varandra i att dricka kaffe med oss. Vi började planera ett konferenstema och grävde ner oss i Custom Post Types, som seriöst är det bästa som hänt WordPress på länge. Förstår ni hur mycket bättre det […]
[…] Custom Post Types in WordPress 3.0 In version 3.0 the developers of WordPress introduce the custom post types. I’m not sure whether it’ll be solely built into the API or also displayed as a GUI somewhere in the settings, but it doesn’t require too much coding skills to add a couple via your functions.php or a perhaps a plugin. […]
Hi,
maybe a bit off-topic, but as i see that your are pretty much expert using CPT: any idea how i can highlight a 'current_page_item' form a 'custom_page'list or why the 'wp_list_pages(post_type=xyz)' doesn't produce any class->current_page_item ?
Thanks a lot
I've never been massive however I've to admit that the iphone is quite good! :) I would wish to know if this challenge about the iphone four is important or not. I might like to buy the brand new one and I was questioning if the calls actually drop more or not. Sorry if it is a bit off topic :P Thanks
[…] Kovshenin Tutorial […]
[…] Custom Post Types in WordPress 3.0 af Konstantin Kovshenin – Indeholder lidt modstridende information omkring de grundlæggende elementer i oprettelse af en ny Indholdstype i forhold til de andre artikler, men har til gengæld en fin gennemgang af hvordan man kan knytte egne admin-kolonner til Egne Indholdstyper […]
[…] Custom Post Types in WordPress 3.0 […]
[…] a WordPress guru, but I did get to play with a couple of cool new features of WordPress; custom post types and […]
[…] cases become even more often these days, due to the new custom post types feature that comes with WordPress 3.0 and provides a much easier way to use posts as other object […]
[…] are some great new features in WordPress 3 including WordPress Multi User integration, additional post types, a new custom menu system, custom taxonomies, background and header image control in the […]
[…] post type to WordPress and you’re away. You can find out more about creating custom post types here.Custom Post Types5. Advanced MenusAlong with all of the other great features bundled with WordPress […]
[…] gaat heeft een van WordPress’ core-developers een technisch verklarende tutorial overgeschreven: “Custom Post Types in WordPress 3.0”. En bekijk WordPress’ Codex voor functies register_post_type […]
[…] the custom post type enhancements introduced in WordPress 3, site builders and plugins developers now have access to what you could […]
[…] had worked with the new wordpress 3.0 release and it was a great opportunity to make use of the new custom post types. I personally think this is one of the best sites I have ever built and enjoyed every minute of it, […]
[…] two pages offer a good walk-through of creating a Custom Post Type and how to customize the columns on […]
[…] to create WordPress Custom Post Types Custom Post Types in WordPress 3.0 WordPress Custom Post Types Guide First Impressions of Custom Post Type Showing custom post types […]
[…] カスタム投稿タイプ機能が強化されています。新しい投稿タイプを追加するのはとても簡単ですので、実際にやってみて、どんなふうになるかチェックしてください ! […]
[…] Custom Post Types in WordPress 3.0 >> via kovshenin […]
[…] the GUI. (Or that I am an idiot who just overlooked it.) Regardless, web developer Konstantin has a great preview of the current custom post functionality, which must be implemented at the PHP code […]
[…] Custom Post Types in WordPress 3.0 […]
[…] Custom Post Types in WordPress 3.0 […]
[…] focuses on how you can have a custom display for certain content, support custom URL structures or manage content differently. These things aren’t new – they are all things you could do previously without too much trouble […]
have trouble to display my custom fields in custom post type do not know how to reference the custom field – does anyone have an idea??
Thank you in advance!
There is a very useful plugin to convert custom fields into terms in a taxonomy : http://scribu.net/wordpress/custom-field-taxonomi…
You could try get_post_custom() ;)
[…] Custom post types in wordpress 30 […]
[…] Custom Post Types in WordPress 3.0 […]
Nice article! One question:
I'm localizing a theme i'm working on. The localization works fine except for the taxonomies and the custom post types. Both keep displaying in the default language.
Anyone who can tell me what could be the reason for that? Or is not possible to localize custom post types and taxonmies?
[…] Custom Post Types in WordPress 3.0 […]
Can any tell me how to make a site like imdb.com in which all links are cross referenced you can arrange movies by actor, director etc.
I am searching for this for past 15 days there are lot of articles on Custom Post Types and Taxonmies but after implementing every article I still not able to make because there is no complete article on this!
Plz help
[…] new function that makes WordPress much more flexible. For those who want an easier option, visit kovshenin.com to learn more about custom post […]
[…] Custom Post Types in WordPress 3.0 […]
[…] Custom Post Types in WordPress 3.0 […]
The 'photo post' is really great addition. I was tired of manually doing this or adding a script for it myself. WP 3 has been nice so far, but I wish the updates would slow down. Feel like a beta tester sometimes.
The photo post is now a post format ;)
Hi – I hope you know about the new "post types" functionality.
see http://wordpress.tv/2011/08/29/ian-stewart-awesom…
It's a great way of customizing posts in a way that's transferable between themes. And it kinda / sorta works in a way that replaces / conflicts with custom post types.
There might be a time when you need both, or would choose to customize post types. But I strongly suggest you watch this video … post formats are wey easy and wey good.
–ben
You mean post formats :)