Forums

rewrite rules for new plugin (2 posts)

  1. EvilDragon
    Member
    Posted 3 months ago #

    Hello I would like to establish two pareallel access to a page that is for example

    seit/var1 but also seite/var/var2 to go

    here is my previous code

    function my_rewrite_rules($rules)
    {
        global $wp_rewrite;
    
        $my_page = 'test';
    
        $my_rule = array(
            'test/(.+)/?' => 'index.php?pagename=' . $my_page . '&my_action=$matches[1]',
            'test/(.+)/(.+)/?' => 'index.php?pagename=' . $my_page . '&my_action=$matches[1]&my_show=$matches[2]'
        );
    
        return array_merge($my_rule, $rules);
    }
    add_filter('page_rewrite_rules', 'my_rewrite_rules');
    
    function my_query_vars($vars)
    {
        $my_vars = array(
            'my_action',
            'my_show'
        );
    
        return array_merge($my_vars, $vars);
    }
    add_filter('query_vars', 'my_query_vars');
  2. EvilDragon
    Member
    Posted 3 months ago #

    it works with:

    function add_query_vars($aVars) {
        $aVars[] = "exc1";
        $aVars[] = "exc2";
        $aVars[] = "exc3";
        return $aVars;
    }
    add_filter('query_vars', 'add_query_vars');
    
    add_rewrite_rule('^produkte/([a-zA-Z_0-9]+)/?$','index.php?page_id=2&exc1=$matches[1]]','top');
    add_rewrite_rule('^produkte/([a-zA-Z_0-9]+)/([a-zA-Z_0-9]+)/?$','index.php?page_id=2&exc1=$matches[1]]&exc2=$matches[2]','top');
    add_rewrite_rule('^produkte/([a-zA-Z_0-9]+)/([a-zA-Z_0-9]+)/([a-zA-Z_0-9]+)/?$','index.php?page_id=2&exc1=$matches[1]]&exc2=$matches[2]&exc3=$matches[3]','top');

Reply

You must log in to post.

About this Topic

Tags