My add_rewrite_rule is returning a 404
Solved. Nginx and WordPress were acting correctly. There was an error condition further down my request processing code.
Solved. Nginx and WordPress were acting correctly. There was an error condition further down my request processing code.
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’);
you may try to de-register/unset default post type and register post type with your requirements. if ( ! function_exists( ‘unset_default_post’ ) ) : function unset_default_post( ) { global $wp_post_types; $post_type=”post”; if ( isset( $wp_post_types[ $post_type ] ) ) { unset( $wp_post_types[ $post_type ] ); return true; } return false; } endif;
Isn’t what you are trying to achieve the point of the rewrite slug? e.g. if you have a news category as press and another as event then simply changing register_taxonomy(‘news_category’, ‘stfp_news’, array( ‘hierarchical’ => true, ‘show_admin_column’ => true, ‘label’ => __(‘Categories’), ‘show_ui’ => true, ‘query_var’ => false, ‘rewrite’ => array( ‘slug’ => ‘about/news/category’), ‘singular_label’ => … Read more
Multisite theme path rewrite using .htaccess
Rewrite tags aren’t used in the context of add_rewrite_rule. If you were to use your tag in the post permalink settings under Settings > Permalinks, then your tag would be present in the link passed to the post_link filter. I think you need to add a new permalink structure containing the tag directly to the … Read more
how to change permalinks format for pagination?
Permalink structure between 2 custom post types and a taxonomy
Canonical url differs from custom post type archive URLs
Well, I explain here what I finally did to sort this out. I haven’t found a proper way to do so but: I created a rewrite function that retrieves all parameters and generates a final URL with the parameters ordered in a specific way. function sc_change_programs_search_url_rewrite() { if(get_query_var( ‘post_type’ ) == ‘program’) { if(isset($_GET[‘word_search’]) || … Read more