Im currently facing an issue with the relationship between pretty permalink and my themes templates.
I have a post type called 'performance', and with pretty permalinks enabled the URLs for the template at single-performance.php looks like this:
www.my-website.com/performance/name-of-performance
In the sidebar of that template, I am listing 5 other performances. This all works fine so far. Standard WordPress stuff.
On another page I am listing all the performances that plays during school hours. This is done with a WP_Query filtering with a meta_query. Still fine.
But this is where I get stuck: When you click one of the school performances it links to the template single-performance.php, and this template has 5 other performances listed in the sidebar. But these are not filtered by school hours. They just show the normal 5 performances.
Is it possible to have an optional parameter in the url so that if it looks like this:
www.my-website.com/performance/name-of-performance
... it lists the normal 5 performances in the sidebar. But if it looks like this:
www.my-website.com/performance/schools/name-of-performance
... it lists 5 performances filtered by the school hours.
In a world without permalink I would simple have this url
www.my-website.com/page_id=12&schools=1
Then in the template i would go
if( isset($_GET['schools'] ) && $_GET['schools'] == 1 ) {
// Show performances filtered by school hours in sidebar
} else {
// Show 5 performances without filtering them
}
Please let me know if this is possible, and if it is, what approach to take.
I have been looking at add_permastruct() add_query_vars filter and add_rewrite_rules() but it all confuses me, as most examples are not solving what I am trying to solve.
/performance/name-of-performance/?schools=1