Skip to main content
logic was not changed, just code reformatting for better visual understanding
Source Link

Here is the answer. And for future references, Deepak, you need to actually post the solution as an answer. Instead, you posted your answer within your own question and then made a comment about it. Please don't do that.

add_filter( 'query_vars', 'analytics_rewrite_add_var' );
function analytics_rewrite_add_var( $vars )
  {
    $vars[] = 'analytic';
    return $vars;
}
add_filter( 'query_vars', 'analytics_rewrite_add_var' );

function add_analytic_rewrite_rule() {
    add_rewrite_tag( '%analytic%', '([^&]+)' );
    add_rewrite_rule(
        '^analytics/([^/]*)/?',
        'index.php?analytic=$matches[1]',
        'top'
    );
   }
add_action('init', 'add_analytic_rewrite_rule');
add_action( 'template_redirect', 'analytics_rewrite_catch' );
function analytics_rewrite_catch()
  {
    global $wp_query;

    if ( array_key_exists( 'analytic', $wp_query->query_vars ) ) {
        include ( get_stylesheet_directory() . '/html/analytics.php');
        exit;
    }
}
add_action( 'template_redirect', 'analytics_rewrite_catch' );

Here is the answer. And for future references, Deepak, you need to actually post the solution as an answer. Instead, you posted your answer within your own question and then made a comment about it. Please don't do that.

add_filter( 'query_vars', 'analytics_rewrite_add_var' );
function analytics_rewrite_add_var( $vars )
 {
$vars[] = 'analytic';
return $vars;
}
function add_analytic_rewrite_rule(){
add_rewrite_tag( '%analytic%', '([^&]+)' );
add_rewrite_rule(
    '^analytics/([^/]*)/?',
    'index.php?analytic=$matches[1]',
    'top'
  );
   }
add_action('init', 'add_analytic_rewrite_rule');
add_action( 'template_redirect', 'analytics_rewrite_catch' );
function analytics_rewrite_catch()
 {
global $wp_query;

if ( array_key_exists( 'analytic', $wp_query->query_vars ) ) {
    include ( get_stylesheet_directory() . '/html/analytics.php');
    exit;
}
}

Here is the answer. And for future references, Deepak, you need to actually post the solution as an answer. Instead, you posted your answer within your own question and then made a comment about it. Please don't do that.

function analytics_rewrite_add_var( $vars ) {
    $vars[] = 'analytic';
    return $vars;
}
add_filter( 'query_vars', 'analytics_rewrite_add_var' );

function add_analytic_rewrite_rule() {
    add_rewrite_tag( '%analytic%', '([^&]+)' );
    add_rewrite_rule(
        '^analytics/([^/]*)/?',
        'index.php?analytic=$matches[1]',
        'top'
    );
}
add_action('init', 'add_analytic_rewrite_rule');

function analytics_rewrite_catch() {
    global $wp_query;

    if ( array_key_exists( 'analytic', $wp_query->query_vars ) ) {
        include ( get_stylesheet_directory() . '/html/analytics.php');
        exit;
    }
}
add_action( 'template_redirect', 'analytics_rewrite_catch' );
deleted 15 characters in body
Source Link
Androliyah
  • 389
  • 5
  • 28

Here is the answer. And for future references, Deepak, you need to actually post the solution as an answer. Instead, you posted your own commentary as an answer and thats probably whywithin your "answer" was voted downown question and then made a comment about it. Please don't do that.

add_filter( 'query_vars', 'analytics_rewrite_add_var' );
function analytics_rewrite_add_var( $vars )
{
$vars[] = 'analytic';
return $vars;
}
function add_analytic_rewrite_rule(){
add_rewrite_tag( '%analytic%', '([^&]+)' );
add_rewrite_rule(
    '^analytics/([^/]*)/?',
    'index.php?analytic=$matches[1]',
    'top'
  );
   }
add_action('init', 'add_analytic_rewrite_rule');
add_action( 'template_redirect', 'analytics_rewrite_catch' );
function analytics_rewrite_catch()
{
global $wp_query;

if ( array_key_exists( 'analytic', $wp_query->query_vars ) ) {
    include ( get_stylesheet_directory() . '/html/analytics.php');
    exit;
}
}

Here is the answer. And for future references, Deepak, you need to actually post the solution as an answer. Instead, you posted your own commentary as an answer and thats probably why your "answer" was voted down. Please don't do that.

add_filter( 'query_vars', 'analytics_rewrite_add_var' );
function analytics_rewrite_add_var( $vars )
{
$vars[] = 'analytic';
return $vars;
}
function add_analytic_rewrite_rule(){
add_rewrite_tag( '%analytic%', '([^&]+)' );
add_rewrite_rule(
    '^analytics/([^/]*)/?',
    'index.php?analytic=$matches[1]',
    'top'
  );
   }
add_action('init', 'add_analytic_rewrite_rule');
add_action( 'template_redirect', 'analytics_rewrite_catch' );
function analytics_rewrite_catch()
{
global $wp_query;

if ( array_key_exists( 'analytic', $wp_query->query_vars ) ) {
    include ( get_stylesheet_directory() . '/html/analytics.php');
    exit;
}
}

Here is the answer. And for future references, Deepak, you need to actually post the solution as an answer. Instead, you posted your answer within your own question and then made a comment about it. Please don't do that.

add_filter( 'query_vars', 'analytics_rewrite_add_var' );
function analytics_rewrite_add_var( $vars )
{
$vars[] = 'analytic';
return $vars;
}
function add_analytic_rewrite_rule(){
add_rewrite_tag( '%analytic%', '([^&]+)' );
add_rewrite_rule(
    '^analytics/([^/]*)/?',
    'index.php?analytic=$matches[1]',
    'top'
  );
   }
add_action('init', 'add_analytic_rewrite_rule');
add_action( 'template_redirect', 'analytics_rewrite_catch' );
function analytics_rewrite_catch()
{
global $wp_query;

if ( array_key_exists( 'analytic', $wp_query->query_vars ) ) {
    include ( get_stylesheet_directory() . '/html/analytics.php');
    exit;
}
}
Source Link
Androliyah
  • 389
  • 5
  • 28

Here is the answer. And for future references, Deepak, you need to actually post the solution as an answer. Instead, you posted your own commentary as an answer and thats probably why your "answer" was voted down. Please don't do that.

add_filter( 'query_vars', 'analytics_rewrite_add_var' );
function analytics_rewrite_add_var( $vars )
{
$vars[] = 'analytic';
return $vars;
}
function add_analytic_rewrite_rule(){
add_rewrite_tag( '%analytic%', '([^&]+)' );
add_rewrite_rule(
    '^analytics/([^/]*)/?',
    'index.php?analytic=$matches[1]',
    'top'
  );
   }
add_action('init', 'add_analytic_rewrite_rule');
add_action( 'template_redirect', 'analytics_rewrite_catch' );
function analytics_rewrite_catch()
{
global $wp_query;

if ( array_key_exists( 'analytic', $wp_query->query_vars ) ) {
    include ( get_stylesheet_directory() . '/html/analytics.php');
    exit;
}
}