Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

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.