I’ve spent days looking all over the web for a working solution to this problem. There are similar issues with resolutions, but I haven’t been able to adapt any of them to my specific problem… or I’m missing something.
In the world of HTML websites, you have:
example.com/events/ <– listing of events
example.com/events/some-event.html <– specific event
I’m developing a WordPress site (locally, so I can’t link to it) using a custom post type of “event” being displayed with the custom post template single-event.php. The page that lists each item from that custom post type uses a custom page template named template-events.php with a title/permalink of “events”.
What I’m trying to do is have the URL (permalink) look and behave just like a user would expect. That is, when someone visits “http://www.example.com/events/”, they see the list of events (looping through the custom post types named “event” and displaying excerpts). When they visit or click through to “http://www.example.com/events/some-event/”, they see the post for that specific event.
Right now I have it set up as:
“example.com/events/ shows the list of events as described above.
“example.com/event/some-event/ shows an event post.
where the event post is using the custom post type name as the slug.
The pages/posts all work individually. I just can’t get that permalink structure to work. I’m not using any custom taxonomies and I don’t have any 404 errors.
'rewrite' => array( 'slug' => 'events', 'with_front' => false ),
when creating a custom post type doesn’t work. The ‘events’ slug conflicts with page permalink of the same name.
I’m tearing my hair out here. Hopefully somebody here can help me with this.