add_rewrite_rules for type of post

the URL index.php?pagename=to-kill-a-mockingbird&post_type=book&book_type=fiction works only for simple post or page. when you have a custom post type, the URL is index.php?book=to-kill-a-mockingbird&book_type=fiction. then try this code : add_rewrite_rule( ‘^books/fiction/([^/]*)/?$’ , ‘index.php?book=$matches[1]&book_type=fiction’ , ‘top’ );

Rewrite Rule for default post type

When you register your custom post type using register_post_type function, you have to be very careful with rewrite param. You should pass an array with following keys: slug => string Customize the permalink structure slug. Defaults to the $post_type value. Should be translatable. with_front => bool Should the permalink structure be prepended with the front … Read more

Should the actual /category/ directory be 404? Is that normal WP behaviour

Yes, it’s normal behavior. WordPress uses a set of rewrite rules to process requests. Here are the rules that will match requests related to categories: [category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2] [category/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2] [category/(.+?)/page/?([0-9]{1,})/?$] => index.php?category_name=$matches[1]&paged=$matches[2] [category/(.+?)/?$] => index.php?category_name=$matches[1] As you can see, all of them require, that the request is longer than /category/. And it makes … Read more

creating custom rewrite rules for admin pages

How would I setup a custom rewrite rule to redirect /wp-admin/(page-slug).php to /wp-admin/admin.php?page=(page-slug) You can’t, WP Admin doesn’t make use of the rewrite rules system like the frontend, so rewrite rules have no effect on WP Admin pages. You can only use WP rewrite rules to map pretty URLs on to versions that take the … Read more

How to overwrite registered taxonomy url from vendor plugin in child theme

You don’t need those custom rewrites and term permalink tweaks, so just remove these and the relevant callbacks: add_action(‘init’,’theme_child_custom_rewrite’, 1000); add_filter( ‘term_link’, ‘listing_region_term_link’, 1, 3 ); And just use the register_taxonomy_args hook to override the taxonomy’s parameters: function override_listing_region_taxonomy_args( $args, $taxonomy ) { if ( ‘listing-region’ === $taxonomy ) { $args[‘rewrite’] = array( ‘slug’ => … Read more

NGINX rewrite rules for sub subdomains

No, sorry, that isn’t going to be possible. Assuming the user connects to your server at https://www.sub.domain.com with HTTPS, the sequence of events will be: the user’s client makes a connection and initiates an SSL negotiation; they will send SNI (= server name indication) that they’re connecting to www.sub.domain.com the server can use the SNI … Read more