[wp-hackers] Slug URL Problems, with Custom Post Type and Pages
johnbillion+wp at gmail.com
Mon Feb 14 19:19:14 UTC 2011
On 14 February 2011 18:49, Robert Lusby <nanogwp at gmail.com> wrote:
> I have a Custom Post Type "Events", using the slug "events".
> So, new events end up at: http://www.example.com/events/event-name
> However I now want to create a static page, using WordPress pages, that sits
> at: http://www.example.com/events/previous
> I've created the Events page, and the Previous page as a child of that.
> The permalink given for this Previous page in WP-Admin is:
> However, visting that page URL gives me a 404 error everytime it loads.
> I've tried reloading permalinks several times, with no luck. Any ideas?
The rewrite rule for your custom post type will be matched by
/events/event-name/. WordPress then tries to find an event with the
name 'event-name', which doesn't exist, giving you a 404.
You can get around this by adding a rewrite rule explicitly for
'/events/previous/' which maps to index.php?pagename=previous. Take a
look at the Plugin Hooks section of WP Rewrite  if you're not sure
how to do this.
More information about the wp-hackers