I’m playing with custom post types in 3.0 beta 2, and so far they look really awesome.
Is there any way to use traditional year/month/day permalinks with a particular custom post type? For example, I have a “News” post type that’s used to list short news blurbs in chronological order. I’d like the permalink of a particular news item to be ordered by date, like how ordinary blog post permalinks work.
So something like this is what I’d love:
Right now it’s just using this:
Q: How can custom post types be set to use my permalink settings?
;In short, they can’t. Custom post types don’t use the permalink setting structure. See Otto’s explanation: http://lists.automattic.com/pipermail/wp-testers/2010-May/013010.html
Ah, that’s too bad. I was hoping I’d be able to hack something up using wp_rewrite, but I couldn’t find any clear documentation for how exactly it works.
Thanks for the response though! Maybe better custom post permalinks for WordPress 3.1? 🙂
Is there no solution to this? I would like to have my NEWS split form my BLOG. I thought I use a NEWS custom post type, but of course I wanted the /news/YEAR/MONTH/postname structure…
There is a solution to this now:
I don’t get the configuration area “Extra permalink settings…” on permalink setting page like the screenshot on your plugin page?
Question: What do you feel about having a custom post type “faq”. Each single “faq item” would get certain categories, which are equal to a product(-name).
Each product has its own subarea in the pages, and among the subpages for the product is a PAGE called “faq”. Can that create any problems?
@iamtakashi My plugin only works with non-hierarchical post types. That’s probably why you’re not seeing the extra fields.
@john – Thanks for your work in putting together this plug-in.
The issue I’ve had with Custom Post Types is that I have not been able to integrate my custom taxonomy in the permalink structure. So for example:
1. I have a custom post type called “portfolio”
2. I have a custom taxonomy called “portfolio-type” – (e.g. website, brand-identity, etc.) that’s linked to my “portfolio” custom post type.
So in a scenario where I create a new portfolio item called “sample” and file it under the “websites” category within my “portfolio-type” taxonomy, I would like for my permalink structure to read:
I installed your plugin and then tried to make my permalink structure ” %post_type%/%portfolio-type%/%postname ” but the url that is generated as:
I have already tried to flush the permalink structure numerous time by visiting the permalink page but to no avail.
Is it simply not possible to add a custom taxonomy to a custom post type permalink structure? Thanks in advance for your feedback, this one has me stumped…
Sorry for the delayed response. Adding custom taxonomy support will be in a future release. I haven’t had the time to make sure I’ve got it working, so it’s just not ready yet. My plugin actually circumvents the whole permalinks functionality for custom post types, so adding the ability to factor in taxonomies involves a decent amount of work (categories are handled by core, so I was able to just use what was already there; this isn’t the case for custom taxonomies, unfortunately). The good news is that someone has made a temporary fork of the plugin available here:
You should be able to replace the main plugin file with that code. I have not actually tested that code, so I cannot vouch for it or offer any support for it, but it was offered as a patch, so if it checks out it’ll be incorporated into the next version.
post_type finally solves the age old need of wanting to have different single.php templates. ( pages do, but too many pages in the database isnt scalable and crashy crashy )
How come the url structure sets itself to what it wants to?
Not acceptable! It even forced itself into the format which is expressedly forbidden by wordpress due to performance reasons of how post url strings are interpereted ( another age old need to fix )
again this really sucks, to be teased with a solution finally, only to have the url borked…
custom-post-permalinks does not work,
it still forces the /post_type/ into the base
so there is basically still no way to have custom post templates. Even if the above work-around-plugins deliver as promised, there is probably still extra database calls
I simply put the following code in my singe.php to be able to switch post_types
if ( have_posts() ) while ( have_posts() ) : the_post(); // post is a news item if (in_category("news")) include("single_news.php"); elseif (in_category("blog")) include("single_blog.php"); else include("single_standard.php"); endwhile; // end of the loop.
@romanczar: Or you could just have single-news.php and it would automatically work for single items in your custom post type.
@cuban_cigar The only time my plugin adds /post_type/ to your permastruct is when your permastruct matches that of the blog post permastruct without it. If your post type needs to look like a page or post, maybe it should be one. Also, the post_type/post_name structure is not a problem the way I’ve done it (for all intents and purposes, the same way WordPress itself does it). If you want to learn the wp_rewrite engine to decide how you would do it better, be my guest. Nobody forces you to use my plugin, or even WordPress for that matter. If it doesn’t suit your needs, maybe you should use something else. Maybe you should try drupal. Your sour attitude and uneducated denunciations lead me to believe you’d fit right in there. Unless you want to take the time to learn the WP_Rewrite API like I did, maybe you shouldn’t tell me the plugin doesn’t work when it does that because I wanted it to PREVENT you from accidentally bringing your whole website down.
Have a nice day!
- The topic ‘Using year/month/day permalinks with custom post types’ is closed to new replies.