Making extra parameters optional

Two points: Your rule isn’t particularly specific. For numeric matches you should be specific about it and specify a) digits and b) how many digits. Year would be ([0-9]{4}), month/day would be ([0-9]{1,2}). You can’t do it with one rule. Add three separate rules instead. add_rewrite_rule( ‘whats-on/([0-9]{4})/?$’, ‘index.php?page_id=71&event_year=$matches[1]’,’top’); add_rewrite_rule( ‘whats-on/([0-9]{4})/([0-9]{1,2})/?$’, ‘index.php?page_id=71&event_year=$matches[1]&event_month=$matches[2]’,’top’); add_rewrite_rule( ‘whats-on/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$’, ‘index.php?page_id=71&event_year=$matches[1]&event_month=$matches[2]&event_day=$matches[3]’,’top’);

How do I flush rewrite rules

I haven’t worked much with flush_rewrite_rules function, but based on the usage notes mention by nmr I think you could perhaps do something like this, add_action( ‘save_post’, ‘my_save_post_function’ ); function my_save_post_function( $post_id ) { $maybe_some_extra_logic = true; // if applicable if ( $maybe_some_extra_logic && ! has_action( ‘shutdown’, ‘my_flush_rewrite_rules’ ) ) { add_action( ‘shutdown’, ‘my_flush_rewrite_rules’, 9999 … Read more

add_rewrite_rule – Additional subpages for author pages

Which works great when going to this URL: http://mylocalsite.site/?author=1&author_view=pinboard Yes, and that is because in that URL, the author value is a user ID. But in the “pretty” version of that URL (e.g. http://mylocalsite.site/author/admin/pinboard), WordPress uses the user’s “nice name” (from the user_nicename column in the wp_users table) which by default is the same as … Read more