How to add several custom parameters in permalink (2 posts)

  1. v_decadence
    Posted 3 years ago #

    I have the page with URL (i.e. http://mysite.com/test) based on defined template. I need to pass 2 parameters ('v' and 'b') to this page using permalink.

    I add this code to functions.php:

    function add_my_var($public_query_vars) {
        $public_query_vars[] = 'v';
        $public_query_vars[] = 'b';
        return $public_query_vars;
    add_filter('query_vars', 'add_my_var');
    function do_rewrite() {
        add_rewrite_rule('^test/([^/]*)/([^/]*)/?$', 'index.php?pagename=test&v=$matches[1]&b=$matches[2]','top');
    add_action('init', 'do_rewrite');

    and this to template file:

    echo get_query_var('v');
    echo get_query_var('b');

    But when I try to access http://mysite.com/test/example1/example2/ I get 404 error. Where am I wrong?

  2. v_decadence
    Posted 3 years ago #

    I don't believe that nobody knows the answer.

Topic Closed

This topic has been closed to new replies.

About this Topic