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

How can I get WordPress to render a page without it adding any addtional html? I'm trying to build a dialog that will work on mobile devices and I only want to show that dialog and not have any of the standard wordpress content around it.

share|improve this question
up vote 2 down vote accepted

You have to implement your own hook for template_redirect action:

add_action( 'template_redirect', 'wpse8170_template_redirect', 1 );
function wpse8170_template_redirect() {
    global $wp_query;

    // check if it is not a page or if it is front page, then exit from the hook
    if ( !$wp_query->is_page() || $wp_query->is_front_page() ) {

    // check queried object, if it is not a specific page, then exit from the hook
    $page = get_queried_object();
    if ( $page->ID != 777 ) { // your page ID 

    // render header

    // ... render your content here ....

    // render footer

share|improve this answer
Beautiful. This is an excellent solution. Thanks so much. – spinlock Feb 15 '13 at 18:02

Make a new template, add your loops, etc, without the HTML present in your desktop site. This is the only way to accomplish what you want.

share|improve this answer
Header and footer should be also dealt with, no? – brasofilo Feb 13 '13 at 20:21
"Not have any of the standard Wordpress content around it" seemed like header and footer should be removed. Can the poster clarify? – smithandteam Feb 15 '13 at 5:27
You should post the comment in the Question itself. Note that many times you need to use @username to address other user. But the author of the Question (or Answer) is always notified, depends on the situation. :::: Just in case: @spinlock, can you give the answerers some feedback? – brasofilo Feb 15 '13 at 5:33
@smithandteam is correct in that I don't want to add WordPress' header and footer. FYI - the usecase is to show a dialog to mobile users and jquery-mobile was conflicting with the rest of the theme. My solution is to isolate the dialog and serve up a stripped down page with jquery-mobile to get the user's response and return to the rest of the site. – spinlock Feb 15 '13 at 18: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.