Worpdress Elementor. How to read query variable from rewrote url in?


I need to create a Elementor page which should have the following URL structure:


At this page I should display a Elementor widget which will display information about order with given orderId.
Whay I reied to do is to create a custom URL rewrite url as follows:

function rewrite_init(){
    add_rewrite_rule('/order/(.*?)-([0-9]+)?$', 'index.php?tag=order_page&order_id=$matches[2]', 'top');
add_action( 'init', 'rewrite_init' );

function order_query_vars( $query_vars ){
    $query_vars[] = 'order_id';
    return $query_vars;
add_filter( 'query_vars', 'order_query_vars' );

Then in my widget I try to read order_id query var by calling get_query_var('order_id')

But when I try to open page like /order/abc-1234

It just redirects me to the

My question is are there any ways to define custom query vars for Elementor driven pages?

, , Andrew Zolotukhin 2 years 2020-01-08T08:40:15-05:00 0 Answers 84 views 0

Leave an answer