Support » Plugins and Hacks » URL Rewrite Question

  • Not sure this is where to put this, but I have a question. What I’m trying to do is the following… When someone hits on my site, they should see the word “bar” and nothing more.. I’m simplifying all of this of course. Here’s my code. This doesn’t seem to be working.

    add_filter( 'query_vars', 'analytics_rewrite_add_var' ); 
    function analytics_rewrite_add_var( $vars )
    	array_push( $vars, 'foo' );
    	return $vars;
    function add_analytic_rewrite_rule($rules){
    	add_rewrite_tag( '%foo%', '([^&]+)' );
    add_action('rewrite_rules_array', 'add_analytic_rewrite_rule');
    add_action( 'template_redirect', 'analytics_rewrite_catch' ); 
    function analytics_rewrite_catch()
    	global $wp_query; 
    	if ( array_key_exists( 'foo', $wp_query->query_vars ) ) { 
    	echo $_GET['foo'];
    function the_unique_rewrite_flush(){
    	global $wp_rewrite;
  • The topic ‘URL Rewrite Question’ is closed to new replies.