I’ve created a unique single post template to give people the option of reading all posts of a certain category using the awesome “reveal.js” which they access via this link
<a href="?show=presentation/">presentation</a>
The problem is the ugly URLs, which end up looking like
website.com/post-name/?show=presentation
website.com/completely-different-post-name/?show=presentation
I would like them to look like
website.com/post-name/presentation/
website.com/completely-different-post-name/presentation/
I’ve spent the last 10 or so hours trying to figure this out (I haven’t even gone to sleep yet, lol); unfortunately, nothing has worked.
Is there a way to do this?
As a side note, the site I’m trying to do this on is installed in a subdirectory (localhost/wp) but I’m developing this for my actual website which is installed in a top level directory
You can achieve this via the Rewrite API‘s
add_rewrite_endpoint
:Then in your template or wherever you differentiate a presentation vs normal view, check the global
$wp_query
for the presence of thepresentation
query var:Note that you need to visit the permalinks settings page after adding the endpoint to flush permalinks and create the new rewrite rules.
EDIT- Output of
$wp_query
insingle.php
: