voceconnect / cms-press

WordPress Plugin
15 stars 2 forks source link

Content types should automatically load content_type.php as a template #48

Closed saddam-azad closed 13 years ago

saddam-azad commented 14 years ago

I have created a Content Type called 'portfolio'

The permalink structure lies at %identifier%/%postname% so that the output is domain.com/portfolio/clientName

I would expect the /portfolio would automatically call portfolio.php file as a template.

And /portfolio/clientName would call single-portfolio.php as a template.

Can this be done?

prettyboymp commented 14 years ago

Both should work. Though single-{post_type}.php is the suggested format. {post_type}.php is only supported for legacy since I released that before core decided to go with the side-{post_type}.php format.

What version are you using?

prettyboymp commented 14 years ago

After re-reading your post, I realized what you were asking. For the loop pages of your post type, you can use: home-{post_type}.php index-{post_type}.php date-{post_type}.php

saddam-azad commented 14 years ago

3.0.1

I am using your plugin to migrate the legacy content_type functions to the new version.

Help is appreciated :)

prettyboymp commented 14 years ago

Are any of the above template names working for you?

saddam-azad commented 14 years ago

index-portfolio.php and single-portfolio.php are working!

Although the permalink structure at %identifier%/%postname% does not work! It works with %post_id%

Is this a bug?

prettyboymp commented 14 years ago

You have to have your normal permalinks setup to use something other than ?p=. Do you have them setup that way?

saddam-azad commented 14 years ago

yes, the normal permalink setup is /2010/09/post-slug/

I wanted my portfolio to show as /portfolio/clientName as the URL. But due to this issue, I am settling with the ID.

prettyboymp commented 14 years ago

Something doesn't sound right. Since you have permalinks setup, using the ID should be redirecting you to the real permalink. What is the format of the permalink when editing a portfolio post?

saddam-azad commented 14 years ago

you get /portfolio/ID (which works)

but /portfolio/clientName does not work when you switch to %identifier%/%post_name% in the Permalink Structure (Edit Content Types)

I hope this is helpful :)

condensed-io commented 13 years ago

I was having the same issue as above, thinking that the permalink structure wasn't working, but the error is just showing before the page is published, after it is published the correct permalink shows up below the title. To save a lot of other users headaches you might want to find out how to make it preview the permalink correctly, I'm just glad it works. Love the plugin by the way!

prettyboymp commented 13 years ago

The permalink isn't set until a post is published because of the way 3.0 handled permalinks a little differently for unpublished posts. As for the %identifier% in the URL, this is different than the name of the post type. This identifier is so that the rewrite rules for the new post type can be unique enough that they don't conflict with others. As long as your site won't have another post type under /album/, then you won't have a problem setting this identifier as such.

condensed-io commented 13 years ago

ok great, good to know it's working correctly, you might want to add it into the FAQs at least, it confused me and I've been making nothing but wordpress sites for years now...

again, I just wanted to say that this plugin is really awesome! thanks so much for writing it.

brent @ mimoymima.com

condensed-io commented 13 years ago

one more thing, version 3.1 added archive support: http://mark.mcwilliams.me/2010/10/wordpress-3-1-introduces-custom-post-type-archives/

is there any way to set has_archive => true within the plugin?

I think this may be the only way to access an archive template without using another plugin, although I'm just now learning about these new features, so I might be missing something. Let me know.

thanks!

condensed-io commented 13 years ago

adding has_archive support is actually a lot more important than I originally thought, I can't find any way to style the archive page without it... making an archive-{$post_type}.php template doesn't seem work without it set :( is this an easy fix?

prettyboymp commented 13 years ago

Archives are already supported, however, since I supported them before core did, the template handling for them is setup to be index-{post_type}.php

condensed-io commented 13 years ago

oh awesome, working now, thanks!