spivurno
11/16/2013 - 3:33 PM

Ounce // Dynamic Pages

Ounce // Dynamic Pages

<?php

add_filter( 'query_vars', array( $this, 'add_login_query_var' ) );
add_action( 'init', array( $this, 'add_login_rewrite_rule' ) );
add_action( 'template_include', array( $this, 'load_login_template' ) );

function add_login_query_var( $vars ) {
    $vars[] = 'login';
    return $vars;
}
    
function add_login_rewrite_rule() {
    add_rewrite_tag( '%login%', '([^&]+)' );
    add_rewrite_rule(
        '^login',
        'index.php?login=1',
        'top'
    );
}

function load_login_template( $template ) {
    global $wp_query;
    if( rgar( $wp_query->query, 'login' ) )
        $template = get_page_template();
    return $template;
}