WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have in my functions.php this function:

// rewrite the url
function my_rewrites_init(){
        'top' );
add_action( 'init', 'my_rewrites_init' );

function my_build_demo_url($p_id)
$demo_url = add_query_arg( array('p_id' => $p_id, 'pagename' =>'demo'), get_home_url() );
return $demo_url;

In my page I have <a href = "<?php echo my_build_demo_url($id)?>" ></a> but I see http://mysite.com/locale/?p_id=105&pagename=demo.

NB: in my WordPress admin I have flushed the permalink.

share|improve this question
What is your question? Your function seems to produce correct output, do you expect or want to achieve different result? – Rarst Jun 5 '13 at 16:30
my question is why url isn't rewrited ? – jmix Jun 5 '13 at 18:01
Which URL? The one you are getting from my_build_demo_url() function? – Rarst Jun 5 '13 at 18:10
rewrite rules parse incoming requests and translate pretty URLs to query vars, but you're not outputting a pretty URL with your my_build_demo_url function, your rewrite rule has nothing to do with this. – Milo Jun 5 '13 at 22:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.