Skip to content

Instantly share code, notes, and snippets.

@thinhbg59
Created September 7, 2017 16:06
Show Gist options
  • Save thinhbg59/a860ffea44e6f856f413f5f465688ddd to your computer and use it in GitHub Desktop.
Save thinhbg59/a860ffea44e6f856f413f5f465688ddd to your computer and use it in GitHub Desktop.
function otff_add_rewrite() {
$url = home_url();
$page_id = 542;
if ( $page_id > 0 ) {
$link = str_replace( $url, '', get_permalink( $page_id ) );
$link = trim( $link, '/' );
add_rewrite_rule( "$link/([^/]+)/page/?([0-9]{1,})/?$", 'index.php?page_id=' . $page_id . '&demo_rw=$matches[1]&paged=$matches[2]', 'top' );
add_rewrite_rule( "$link/([^/]+)/?$", 'index.php?page_id=' . $page_id . '&demo_rw=$matches[1]', 'top' );
}
add_rewrite_tag( '%demo_rw%', '([^/]+)' );
}
add_action( 'init', 'otff_add_rewrite' );
@thinhbg59
Copy link
Author

@thinhbg59
Copy link
Author

                    $rw = get_query_var('demo_rw');
                    var_dump($rw);
                    $a = $_GET['demo'];
                    var_dump($a);
                    die;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment