add_rewrite_rule() returns 404 page
add_rewrite_rule() returns 404 page
add_rewrite_rule() returns 404 page
As answer provided by @tmdesigned in comments above. An extra step is needed, to go to settings and resave permalinks.
I think you should do something like this: function my_rewrite_rule() { add_rewrite_rule(‘^prefix/section/([0-9]+)/([^/]*)?’, ‘index.php?section=$matches[1]&name=$matches[2]&post_type=post’, ‘top’); } add_action(‘init’, ‘my_rewrite_rule’); Add a query var for section: function my_query_vars( $vars ) { $vars[] = ‘section’; return $vars; } add_action( ‘query_vars’, ‘my_query_vars’ ); I created the pattern for your section (which can be 1 or 2) and used $matches[2] to … Read more
You are getting a ‘page not found’ because it is exactly that, not found. What you can do is create a page, for instance, called ‘locations’ then set it up like this example.com/locations/the-hamptons => index.php?page_id=[id_of_locations]&filter=the-hamptons
What you need is to register your own Rewrite Rule. To do it you should use add_rewrite_rule function. function my_custom_external_rewrite_rule() { add_rewrite_rule(‘^post-type-name/([^/]+)/?’, ‘index.php?page_id=<PAGE_ID>&external_page_name=$matches[1]’, ‘top’); } add_action( ‘init’, ‘my_custom_external_rewrite_rule’ ); And you’ll have to register your custom query variable (using query_vars hook): function my_custom_external_query_var( $query_vars ) { $query_vars[] = ‘external_page_name’; return $query_vars; } add_filter( ‘query_vars’, ‘my_custom_external_query_var’ … Read more
After lots of pulling my hair out I figured out the problem. I needed to use the add_rewrite_tag() function to tell wordpress to allow my query vars. function prefix_movie_rewrite_rule() { add_rewrite_tag(‘%state_id%’, ‘([A-Za-z0-9\-\_]+)’); add_rewrite_tag(‘%state%’, ‘([A-Za-z0-9\-\_]+)’); add_rewrite_rule ( ‘states/([A-Za-z0-9\-\_]+)/([A-Za-z0-9\-\_]+)’, ‘index.php? state_id=$matches[1]&state=$matches[2]’, ‘top’ ); } add_action( ‘init’, ‘prefix_movie_rewrite_rule’);
plugin: rewrite rules are lost when WP updates
Custom Post Type parent/child relationship rewrite rules for permalinks
You are specifying the same slug of lyrics for both your custom taxonomies. WordPress by default cannot share the same slugs for two taxonomies due to WordPress’ rewrite API. Which caters for the default nature of posts, archives, taxonomies, slugs and the WordPress template hierarchy. To prevent your 404 errors you can change your artists … Read more
Homepage rewrite rule