Unless you declare $wp_rewrite
as a global in your test function, you’ll be trying to access the local variable $wp_rewrite
. This, of course, won’t work.
Add the line global $wp_rewrite;
:
<?php
add_action('init', 'test');
function test()
{
global $wp_rewrite;
$reply_struct="/reply/%reply_id%";
$wp_rewrite->add_rewrite_tag('%reply_id%', '([^/]+)', 'reply_id=$matches[1]');
$wp_rewrite->add_permastruct('reply_id', $reply_struct, false);
}