Tag archive: custom post types

Custom post types, authors, and custom roles

When you create a custom post type in WordPress, you can set it to ‘support’ a number of things: a featured image, trackbacks, revisions… and author. You might want to use it in the way author is used for core posts, literally the credited author of a post. Or maybe you could use it to give a bit more granularity to user permissions. The ‘owner’ of a post, if you will. Great!

Well, that’s what I wanted to do. Turns out it’s a little more complicated…

Read more »

Get post ID from custom post type URLs as well

url_to_postid is a great core WordPress function. Give it a URL (from your own site!) and it’ll return the ID of the post or page it refers to. I’m using it so clients can paste a URL into a custom field (easy for them), then I can get other stuff related to the content using the ID (easy for me).

But it doesn’t seem to handle custom post type URLs. So I wrote a little workaround…

Read more »

Custom fields for custom post types

I’ve just updated my most popular post, Control Your Own WordPress Custom Fields. It’s a long-overdue change, which allows for custom post types.

One thing is, as far as I can tell, when you set properties in PHP classes, you can’t use “dynamic” values. In the new version, there’s a property called $postTypes. I wanted to use get_post_types() to dynamically include public custom post types as well as the standard “post” and “page”, but I kept getting “unexpected (” errors. For now, I’ve hard-coded an array that can be added to. Does anyone know a more elegant solution? The only thing I can think of is using a method, though maybe I’m misunderstanding what I’m doing in terms of using a property.

Anyway, I’ve re-opened the comments over there, so do chip in with ideas!

Complete archive

Main index