Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have an issue with a site running on WP 3.3 where when we make the permalink anything by "/%post_id%/%postname%/", the archive pages break and become 404s.

After some research, I came to understand why from a performance perspective, this is not a good practice, so I tried the suggested alternatives: "/%year%/%postname%/" and "/%post_id%/%postname%/"

Both suggestions worked, except that only with the post_id one, did archive urls become "/date/2012/11/" for example, and were found. Under any other permalink suggestion, they just were "/2012/11/" for example, and produced 404s.

Now the question is why does WP only put the word "date" in when the permalink is "/%post_id%/%postname%/"?

I figure it works with the "date" parts because it matches to "/date/%year%/%month%/".

As note, category and tag urls came out as usual and worked: example "/category/news" and "/tag/advice/".

share|improve this question
add comment

1 Answer 1

Now the question is why does WP only put the word "date" in when the permalink is "/%post_id%/%postname%/"?

Because the WP_Rewrite class method get_date_permastruct only looks specifically for a clash between %date% and %post_id% tags.

To get this date structure with other numeric-based post permalink structures, you can manipulate the date structure directly:

function wpa57228_date_structure() {
    global $wp_rewrite;
    $wp_rewrite->date_structure = $wp_rewrite->front . 'date/%year%/%monthnum%/%day%';
}
add_action( 'init', 'wpa57228_date_structure' );
share|improve this answer
add comment

Your Answer

 
discard

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.