I'm struggling a bit with the permalinks on yearly archives for a custom post type.

I'm using wp_get_archives to get a list of the yearly archives but the url for these comes out as follows:


I would like the urls to match this pattern:


I followed the example in this answer but the urls are still outputed as in my first example.

public function urlRewrites(){

I also tried the solution mentioned here. This one changes the urls I get from wp_get_archives but they return 404s and has a trailing querystring.


Example code:

public function urlRewritesAgain(){
    global $wp_rewrite;
    $wp_rewrite->date_structure = 'reports/%year%/%monthnum%/%day%';

I am resaving my permalinks each time and I am hooking on to init. Am I doing something massively wrong here? Is there a better solution I should be using?



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.