I think you just have to add kategori
to the array of query vars:
EDIT- after much iteration we’ve arrived at a solution. the original code seemed to be working, but only with specific permalink settings, as I was mistakenly routing to a post instead of a page. rather than p=
, it should be pagename=
, with both the parent and child page in the path:
function setup_filter_rewrites()
{
add_rewrite_rule('sok/events/([^/]*)/?', 'index.php?pagename=sok/events&kategori=$matches[1]', 'top');
}
add_action( 'init', 'setup_filter_rewrites' );
function setup_filter_query_vars( $query_vars )
{
$query_vars[] = 'kategori';
return $query_vars;
}
add_filter( 'query_vars', 'setup_filter_query_vars' );
Related Posts:
- why is are these rewrite_tags and rules not working?
- Redirect taxonomy to custom template to list terms in taxonomy
- Multiple values in a rewrite rule, is it possible?
- What add_rewrite_tag()’s RegEx matches against?
- add_rewrite_endpoint not working
- Why isn’t my rewrite rule working when there is no second parameter?
- Passing variables in the permalink structure on a custom post type
- When should add_rewrite_tag() be used?
- Why does everybody hook add_rewrite_rule on init
- add_rewrite_rule() vs $wp_rewrite->rules vs ‘rewrite_rules_array’?
- How to check if a rewrite rule exists
- add_rewrite_rule not producing anything in $_GET
- Flush_rewrite_rules not working when settings updated
- Case-insensitive add_rewrite_rules in WordPress functions
- flush_rewrite_rules() cancels the effect of add_rewrite_rule()
- Separate posts by chapter per rewrite
- Using add_rewrite_rule() to redirect to Front Page
- Permalinks, Rewrites, Get Variables, Oh My!
- add_rewrite_rule parameter is not received by the page
- add_rewrite_rules prefix everything
- Can someone explain the function of the third parameter of “add_rewrite_tag”
- How to restore WP 5.4 behaviour where a numeric string could added to each page URL and parsed as “page” in WP 5.5?
- get_query_var with add_rewrite_rule and add_filter(‘query_vars’) not working
- Can rewrites fallback if 404? Rewrite conflict issue
- Reading Settings -> Front Page displays “Static Page” being reset
- add_rewrite_rule query_var not being set
- why does add_rewrite_rule refresh and loose url variables
- Where do I USE add_rewrite_rule?
- add_rewrite_rule confusion
- Custom Rewrite rule to match anything not already matched by WordPress
- Uppercase to Lowercase in URL
- How to add custom variable in url without redirect?
- Hooking “delete_option_rewrite_rules” for rewrite rule addition
- WordPress shows front page, when it should show 404 with pagination style urls
- Rewrite URLs – Custom Post Type – Post Slug, Taxonamy Slug
- Rewrite rule problem
- add_rewrite_rule redirects if value = 1
- Pass query vars to front page
- Custom permalink leads to index page
- add_rewrite_rule permalinks break in WordPress 4.5
- How to add rewrite rule for external php file
- Help with rewrite rules for two post types
- How to flush rewrite rules on the activation of any plugin
- How to test custom rewrite rules /permalinks?
- Rewrite without query parameter
- Mod_rewritte – remove ?m=1 from url
- Rewrite Rules problem when rule includes homepage slug
- Custom Post Type posts, conflict with posts after add_rewrite_rule to top
- Combine multiple CPT names to create valid permalinks
- WooCommerce – Conditional for page created by rewrite_rule
- flush_rewrite_rules() not working on updating Settings API
- Rewrite rules priority
- Rewrite rules for short URL
- How do I turn off the blog and archives?
- Grab last part of the url inside rule
- How to do make mysite.com/post-name/sub-post?
- Custom rewrite rules for a page with GET variables?
- How to change an existing wordpress page rewrite rule?
- WordPress add a rewrite rule to a page to accept a GET variable
- “/” URLs without trailing slash shows 404
- How can I resolve search error with pagination wordpress
- wordpress path generation from rewrite rule
- CPT – Nice url with add_rewrite_rule
- Multiple Taxonomy Items for Separate URLs
- add_rewrite_rule only works when flush first
- WordPress add_rewrite_rule with 2 variables
- Rewrite rule not working, issue may be in URI request
- custom rewrite rules will not be added to wordpress rewrite_rules database
- Overcoming a complex WordPress page rewrite rules request
- How to create a custom URL to another domain in WordPress
- Custom Fields Query Vars and Rewrite not working
- Rewrite Rules, Query Vars and Pagination
- Pretty links with add_rewrite_rule and add_query_var
- Create new URL structure for custom post types
- How to change URL in WordPress
- WordPress Rewrite rule with custom query var
- default ‘post’ post type: not forcing url rewrite when args set
- How to add rewrite rule to point to file
- Last query_var not working with rewritten URL
- How to use endpoint, but remove/rewrite endpoint base?
- add_rewrite_rule doesn’t work for me
- Rewritten URL not loading WordPress environment
- WordPress Custom post type single page 404 error
- Custom Rewrite Tag Structure
- Rewriting base name Taxonomy same Post Type
- Rewrite for page with a possible unknown parent page
- Rewrite the WordPress URL from custom plugin
- add_rewrite_rule works only with one “directory”
- URL Rewrite for CPT single posts
- Rewrite rule help for gallery plugin
- How to Add Rewrite Ruled Argument Into Permalink Properly
- add_rewrite_rule() driving me crazy, rewrite not working when analyzer says it should
- Redirect to a file in a WordPress theme directory
- Rewrite URLs in a Custom Post Type with Multiple Taxonomies
- What is the `rewrite_rules` option the options table in the WordPress database?
- add_rewrite_rule doesn’t work when trying to add a new parameter at the end of URL
- Direct domain alias to a specific WordPress page without the page in the URL
- rewriteRules WP6
- WordPress rewrite rule – not able to access second and third parameters
- Custom URL Rewrite Rules not working