WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


I would like them to look like


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

share|improve this question
up vote 1 down vote accepted

You can achieve this via the Rewrite API's add_rewrite_endpoint:

function wpa89344_add_presentation_endpoint(){
    add_rewrite_endpoint( 'presentation', EP_PERMALINK );
add_action('init', 'wpa89344_add_presentation_endpoint');

Then in your template or wherever you differentiate a presentation vs normal view, check the global $wp_query for the presence of the presentation query var:

global $wp_query;
if( isset( $wp_query->query_vars['presentation'] ) ){
    include(TEMPLATEPATH . "/single_wide_report.php");
} else {
    include(TEMPLATEPATH . "/single_normal_report.php");

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 in single.php:

enter image description here

share|improve this answer
thanks Milo! Looks like I had the first part right (at one point); could you explain the second part just a bit more for me. At the moment I'm calling both templates with switch ($_GET["show"]) { case "presentation": include(TEMPLATEPATH . "/single_wide_report.php"); break; default: include(TEMPLATEPATH . "/single_normal_report.php"); break; } – John Mar 4 '13 at 18:11
see edit above. – Milo Mar 4 '13 at 18:30
is there supposed to be a semi-colon after global $wp_query? Without one, my posts go blank on me. With a semi-colon, though, I can't access the presentations template at all (even with the old ?show=presentation) Probably I'm missing something. – John Mar 4 '13 at 18:43
yeah, sorry, missing the semicolon. enable debugging to see php errors. have you flushed permalinks? view the $wp_query global to see if the query var is being set: print_r($wp_query);. – Milo Mar 4 '13 at 18:47
no worries, I'm learning lots. Everything's clear with the debug, there weren't any errors. And I'm flushing permalinks. Lastly, I added print_r($wp_query); to single_normal_report.php I'm not too sure what to look for though. Didn't see any reference to the templates – John Mar 4 '13 at 19:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.