Passing variables through permalink structure

Solved it!

// Register the variables that will be used as parameters on the url
function add_my_var($public_query_vars) {
    $public_query_vars[] = 'extra_slug';
    return $public_query_vars;
}
add_filter('query_vars', 'add_my_var');

// Build the rewrite rules, for the extra parameter
function do_rewrite() {
    add_rewrite_rule('(accommodation)/[/]?([^/]*)$', 'index.php?pagename=accommodation&extra_slug=$matches[2]','top');
}
add_action('init', 'do_rewrite');

// The parameter is now accessible
get_query_var('extra_slug')

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)