I have a custom post type called event. The URL structure looks like this.
http://my-url.com/events/2016/08/21/workshop
Where “workshop” is the name of the event. Right now the template will show different data depending on the query string. For example this URL:
http://my-url.com/events/2016/08/21/workshop?sub=files
Will loop out some files. I’m adding the query string so i can do that in the same template.
<?php
$sub = isset( $_GET['sub'] ) ? $_GET['sub'] : null;
switch ( $sub ) {
case "files":
echo "TODO: Loop out files";
break;
case "participants":
echo "TODO: Loop out participants";
break;
case "agenda":
echo "TODO: Write out the agenda!";
break;
<!-- etc -->
}
?>
But i don’t like this URL structure! I’d like the URL to be:
http://my-url.com/events/2016/08/21/workshop/files
So that i in the “Event” template (/workshop/
) can look at the URL structure instead of the query string. The problem is that adding /files
to the URL will make wordpress look for a page that doesn’t exist and give a 404.
Is it possible to do some URL wizardry so the template (and post data) of this url:
http://my-url.com/events/2016/08/21/workshop/
Also kicks in with this URL:
http://my-url.com/events/2016/08/21/workshop/agenda/