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

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

share|improve this question
Did you flush your rewrite rules? (Go to settings > permalinks) – Rob Vermeer Jan 18 '12 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 :( – Umesh Awasthi Jan 18 '12 at 16:27
up vote 2 down vote accepted

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');
share|improve this answer
no, its still giving me 404.i even lush your rewrite rules by (settings > permalinks) – Umesh Awasthi Jan 18 '12 at 16:39
Strange... If you change the rewriterule to add_rewrite_rule('writer/([^/]*)','index.php?pagename=writer&args=$matches[1]',‌​'top'); – Rob Vermeer Jan 18 '12 at 16:41
still same problem 404. I am using WAMP server. – Umesh Awasthi Jan 18 '12 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? – Rob Vermeer Jan 18 '12 at 16:51
strange..will try that, but i believe if this is working for you should work for me also – Umesh Awasthi Jan 18 '12 at 17:01

Your Answer


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

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