Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

And when I use the permalink editor to add a base, it messes up my author links.

My current url structure is www.example.com/123 (123 being post_id) And my author URL is www.example.com/author-name (no base)

And when I use the permalink editor to add a base, it messes up my author links.

What is the code to add a post base with the htaccess file?

share|improve this question
Can you give an example of what and how you want to access (the url)? – Rutwick Gangurde Oct 18 '11 at 4:15
i want the post url to be 'www.example.com/posts/post-id' – Jack Stewart Oct 18 '11 at 4:17
Did you try this in 'Permalinks > Custom Structure' : /posts/%post_id% ? – Rutwick Gangurde Oct 18 '11 at 4:27
I did, but it corrupts the author link by adding "/posts" into the author link as well – Jack Stewart Oct 18 '11 at 4:29

closed as not a real question by toscho Jul 18 '12 at 21:22

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer

You can add a custom rewrite rule into your function php:

function add_rewrite_rules($aRules) {
    $aNewRules = array('posts/([^/]+)/?$' => 'index.php?p=$matches[1]');
    $aRules = $aNewRules + $aRules;
    return $aRules;
}
//hook add_rewrite_rules 
//function into rewrite_rules_array
add_filter('rewrite_rules_array', 'add_rewrite_rules'); 

You have to visit the permalinks settings page once to flush rewrite rules after adding this bit of code.

That should work (didn't tried it though).

share|improve this answer
didnt work, ill figure it out somehow – Jack Stewart Oct 18 '11 at 16:56
I just tested it on a fresh install + twenty eleven and it's working. Did you visit the permalinks settings page to make sure the rewrite rules are flushed? Can you describe what is not working precisely ? – Jonathan Liuti Oct 19 '11 at 17:58

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