Date-based permalinks for Custom Post Type, and custom taxonomy permalinks

We’ll start with the taxonomies, as those are fairly simple. If you register those with simply reading/genre and reading/author as the slug argument, those should work without issue.

The post type is a bit more tricky. For that, we register with the rewrite argument set to just true. Then we add a new permastruct for that post type with:

add_permastruct(
    'pg_review',
    "/reading/%year%/%monthnum%/%day%/%pg_review%/",
    array( 'with_front' => false )
);

We’ll now have the rules for single post views, but the year/month/day views will all have the wrong post type set, so we’ll add some new rules to reset those with:

add_rewrite_rule(
    '^reading/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$',
    'index.php?post_type=pg_review&year=$matches[1]&monthnum=$matches[2]&day=$matches[3]',
    'top'
);
add_rewrite_rule(
    '^reading/([0-9]{4})/([0-9]{1,2})/?$',
    'index.php?post_type=pg_review&year=$matches[1]&monthnum=$matches[2]',
    'top'
);
add_rewrite_rule(
    '^reading/([0-9]{4})/?$',
    'index.php?post_type=pg_review&year=$matches[1]',
    'top'
);

The last step is to filter post_type_link to insert the correct year/month/day in the permalinks:

function wpd_pg_review_permalinks( $url, $post ) {
    if ( 'pg_review' == get_post_type( $post ) ) {
        $url = str_replace( "%year%", get_the_date('Y'), $url );
        $url = str_replace( "%monthnum%", get_the_date('m'), $url );
        $url = str_replace( "%day%", get_the_date('d'), $url );
    }
    return $url;
}
add_filter( 'post_type_link', 'wpd_pg_review_permalinks', 10, 2 );