Custom Post Type Templates In Wordpress - wordpress

I don't suppose anyone is aware of whether custom post types can have custom templates just like posts in WP? I've found no documentation on this on the codex and can't really find any relevant material. I'd have assumed WP 3.1 supports this but there's no mention to it. It seems like a black hole that someone must know about?
Apologies for the very generic, open-ended question. I know about custom post types and have implemented them, it's just this seems undocumented.

What do you mean by "templates"? Are you using the term in the same way WP defines it? If so, they seem to be supported: http://codex.wordpress.org/Post_Types#Custom_Types
In the form of the
single-type-template. In the same way
that posts are shown on their own page
with single.php, custom post types
will use single-{posttype}.php if it's
available.

Related

Creating a custom permalink structure based on post fields

I am wondering if it is possible to create a bespoke permalink structure which is based off some of the custom fields I have in my post.
The custom post fields are: film_director, film_name (these will be consitent through out the website)
So the structure I would like to create is as follows:
http://domain.com/%film_director%/%film_name%/%postname%
I'm not great with Wordpress specific terminology so I might just be looking with the wrong keywords however is this something that can be completed (with use of either a plugin or custom code)
Thanks :)
Yep you can do this : here is a nice tutorial about it : http://firecask.com/custom-fields-and-posts-in-wordpress-permalink-urls/
I also find a plugin which seems to do this, but it's quite an old one. http://wordpress.org/plugins/custom-fields-permalink/

wp email publishing with custom content type?

having researched wp forums and only found people asking this question without any answers, I resort to the source of all truth (stack overflow).
I use wordpress custom post types (Custom Post Type UI plugin) and find it very handy.
Now, I want to be able to email-publish some content via WPs built-in email publishing system, but by default that is set up to only publish as regular posts.
I am aware that I can choose categories for the emailed content, but I would very much like to keep all the pages and content of my news (=blogposts) feeds the way they are, being able to put the email-published content into a content type of its own would really help me out.
So I wonder if anyone has done that, and how you would go about it. Thanks for any input.
Not sure if this helps people looking for a solution, but I managed to do it like this...
When a post is submitted for publish by WordPress default email2post, there is an action hook named 'publish_phone' running, so you can get the post there and change its type like this:
add_action('publish_phone','custom_type_by_mail');
function custom_type_by_mail($post_id){
$p = get_post($post_id,'ARRAY_A');
$p['post_type'] = "my-custom-type";
wp_update_post($p);
}
I resorted to converting it into a post category instead of its own content type. I know not whether there be any other solution =)

Wordpress, Setting language for each post?

I have a blog and I want to write some posts in spanish and some other in english (no post will be in both languages).
So, I want to be able change the value returned by language_attributes() function for certain posts. I've seen that language_attributes() uses get_bloginfo('language'). So I guess in wordpress, language is designed to be at 'the whole site' level rather than at 'post' or 'page' level.
I think I only have two solutions: to write a plugin in which I can define the language for each post (which would have to use a filter like here. Or to use a multi-language plugin, which is a too sophisticated solution for my simple problem.
Any other ideas? Any other plugin o simple solution?
thanks
There are plug-ins already available for setting up a multilingual WordPress blog. You might want to have a look into this topic: http://codex.wordpress.org/Multilingual_WordPress. So, you could use an existing plug-in.

Wordpress custom post type and permalink rewriting

I'm struggling with a problem I'm not able too solve.
I've spent a lot of hourse in codex documentation without any luck.
I've created a custom post type called "Products". Products will be available in many language. Products permalink is something like: mysite.com/products/product-name What I need instead is something like this: mysite.com/language/products/product-name.
What I need to create the permalink? Have I to add some fancy rule with WP_Rewrite?
Is it possibile to have custom post type as page child's?
I don't really need custom taxonomy so if you know a better solution fell free to write.
Thanks for any suggestion.
You need a plugin for wordpress to gracefully handle multiple languages.
I suggest you check out wpml.org
For how the Wordpress Multilingual plugin works with custom posts types, check out their informative blog post.

WP: writing an admin plugin for managing custom content

A client of mine has a site in wordpress, with one section being a directory of agents that each have different text and videos associated with them.
The client wants to be able to easily add/remove/change these agents from within the wordpress admin interface. There will be anywhere from 50-75 of these agents, so doing each page manually is not very attractive.
We currently have 3 agents added as posts, and i understand that we can store additional information inside the post itself, so that is not a problem. What we would like to create is a simpler way of managing those pages where the content cannot be changed by the maintainer, and the additional fields on the post are hard coded so there would be no room for user error.
What i am interested in is if anyone has done something similar in the past and can share their approach and experience, or if anyone can point me in the right direction as to how i can accomplish this and what i need to be aware of.
Thanks.
Yes, Custom Post Types are a perfect fit for your needs. Here are some links to articles explaining them:
http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress
http://www.wpbeginner.com/wp-tutorials/how-to-use-custom-post-types/
http://thinkvitamin.com/dev/create-your-first-wordpress-custom-post-type/
You can use a plugin like Custom Post Type UI or just add the register_post_type() calls to your theme's functions.php file:
http://wordpress.org/extend/plugins/custom-post-type-ui/
Then you can use a plugin like "Simple Fields" to add metaboxes to your Agent post type (although there are numerous plugins offering similar functionality; I'm building one myself!):
http://eskapism.se/code-playground/simple-fields/
Hope this helps...
Have you thought about using custom post types? You could create type called Agent and then each agent would be like a post. That way you could search for specific agents easily in the admin and then go in to the post for each agent to change their details.

Resources