I have a problem with adding a new Rewrite rule. Although the code seems to be correct, it doesn’t add a rule to the database. Ofc I flushed the rules manually.

add_action( 'init', 'wpa5413_init' );
function wpa5413_init()
{
    add_rewrite_rule(
        'ogloszenie/([^/]+)/?',
         'index.php?pagename=ogloszenie&q=$matches[1]',
        'top' );
}
add_filter( 'query_vars', 'wpa5413_query_vars' );
function wpa5413_query_vars( $query_vars )
{
    $query_vars[] = 'q';
    return $query_vars;
}

My link looks like this: http://example.com/ogloszenie/?q=some_number
And I want this: http://example.com/ogloszenie/some_number

In my other site this code works perfectly fine. But when I add this to my friends site (also in wordpress) it doesn’t. What could be wrong?

Read more here: Add_rewrite_rule doesn’t add rule to DB


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: