My Question is almost similar to author-specific-urls-in-wordpress and mapping-multiple-urls-to-same-page-in-wordpress. And i have followed the following steps

  1. Created a custom page (writer.php)
  2. Associated that page from dashboard

since all the writer are not being registered with word-press so WP build in author functionality is not of any help for me. So i created a custom URL something like

$author_page_url = home_url( '/' );
$author_page_url .='writer/'.$author_id[0];

where author_id is being fetched from the database.i have following entry in my function.php

add_action('init', 'add_my_rule');      
    function add_my_rule()     {    
            global $wp; 

and on writer.php i am doing something like

$params = get_query_var('args'); 
            $ppp = get_option('posts_per_page');
            if (!is_paged()) {
                    $custom_offset = 0;
            } else {
                $custom_offset = $ppp*($paged-1);   
            $args = array( 'meta_key' => 'writer', 'meta_value' => $params 
                       ,'numberposts' => $ppp,'offset' => $custom_offset);

My problem is when i am hitting the following URL http://localhost/blog/wordpress/writer/umesh-awasthi WP is giving me 404 Error.while the URL http://localhost/blog/wordpress/writer/ is working perfectly fine.

Initialy when i developed this, it was working fine and now i have no clue what is going wrong. Can any one help me to debug the problem.Thanks in advance.


My initial doubt is that the rewrite rule is not working but not sure why

  • Did you flush your rewrite rules? (Go to settings > permalinks) Commented Jan 18, 2012 at 16:24
  • @RobVermeer you mean hitting the save button? if this is the case yes i already did it many times but it did not worked :( Commented Jan 18, 2012 at 16:27

1 Answer 1


Your example works if I delete the newline.

So this should work:

function add_my_rule() {    
    add_rewrite_tag("%args%", '([^/]*)', 'args=');
add_action('init', 'add_my_rule');
  • no, its still giving me 404.i even lush your rewrite rules by (settings > permalinks) Commented Jan 18, 2012 at 16:39
  • Strange... If you change the rewriterule to add_rewrite_rule('writer/([^/]*)','index.php?pagename=writer&args=$matches[1]','top'); Commented Jan 18, 2012 at 16:41
  • still same problem 404. I am using WAMP server. Commented Jan 18, 2012 at 16:45
  • I installed a fresh WP install on my wamp, added the code and page (writer) and then if I go to /writer/umesh-awasthi/ it works. So can you try this in a default theme, like twenty-eleven? Commented Jan 18, 2012 at 16:51
  • strange..will try that, but i believe if this is working for you should work for me also Commented Jan 18, 2012 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.