[wp-trac] [WordPress Trac] #13818: There should be index pages for custom post types
WordPress Trac
wp-trac at lists.automattic.com
Thu Oct 14 10:40:16 UTC 2010
#13818: There should be index pages for custom post types
----------------------------+-----------------------------------------------
Reporter: frankieroberto | Owner: nacin
Type: task (blessed) | Status: accepted
Priority: normal | Milestone: 3.1
Component: Template | Version: 3.0
Severity: normal | Keywords: needs-patch
----------------------------+-----------------------------------------------
Comment(by nacin):
In [15803], I've added a few new pieces to the `rewrite` flag when
registering a post type. Generally that flag is a boolean, but
increasingly plugins will be using it as an array:
- `archive`: Default false. True if you want this post type to include an
archive. If this is a string, then that will be the archive slug used in
lieu of the post type.
- `feeds`: Default false. True if you want feeds as well. `archive`
cannot be false.
These already existed:
- `with_front`: Default true. Whether to prepend the front base. (When
home and site urls differ.)
- `slug`: Defaults to the post type. You can change the slug here. Note
that `archive` actually falls back to this value first.
The rewrites are kind of lame as they're straight add_rule() calls, but
there's no easier way to do it without starting to move a lot of post type
(and presumably taxonomy) logic into rewrite.php, which I imagine is
something for a future pass or even version.
Post type archives are now is_archive = true. Previously, if done via a
plugin, they were is_home = true, which was a bug as query.php is not
particularly post_type-aware.
is_archive() can now check if you are on a post type archive by specifying
a post type as a parameter. Note that if the plugin is for whatever reason
pulling in multiple post types onto the page, then is_archive() with a
post type specified should be considered unreliable.
is_archive(array('post', 'page')) only checks that you are on an archive
of posts or pages, not an archive of posts AND pages.
A new archive-{$post_type}.php template is now functional. Post type
archives now fall back to archive.php.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/13818#comment:31>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list