Multisite wordpress and subdomain URL collisions

You could just prevent slugs matching existing directories. There are two filters for that. Example, not tested: add_filter( ‘wp_unique_post_slug_is_bad_hierarchical_slug’, ‘prevent_directory_slugs’, 10, 2 ); add_filter( ‘wp_unique_post_slug_is_bad_flat_slug’, ‘prevent_directory_slugs’, 10, 2 ); function prevent_directory_slugs( $bool, $slug ) { return is_dir( ABSPATH . “https://wordpress.stackexchange.com/” . $slug ); }

Prepend meta_value to permalink of post

In this case it seems like you’ll want to hook into the WordPress rewrite rules. {$permastruct}_rewrite_rules doesn’t have a lot of information, but this filter would allow you modify the array of existing rewrite rules to add in your new rewrite rule for series. For this to work: http://example.com/series/movie_slug/parrent_series_slug/series_slug You’ll need to add in movie_slug, … Read more

Rewrite category slug

It can be done by writing a code on post_link filter. This filter allows you to change the final post link. Since you are showing categories in your permalink, so I am assuming that your permalink structure contains %category% in it. Below code will help you to get links the way you want. add_filter( ‘post_link’, … Read more

Custom rewrite rules are sending everything to index.php

Finally figured it out. 1) I was calling the first function at ‘rewrite_rules_array’ instead of ‘init’ which was just dumb. 2) There was still something wrong with it, but I explored another area that seems obvious now, but which I originally glossed over because it seemed to be. https://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint https://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/ Just make an endpoint. WordPress … Read more

WordPress URL rewrite regex

From the wordpress documentations – https://codex.wordpress.org/Using_Permalinks Using %category% with multiple categories on a post When you assign multiple categories to a post, only one can show up in the permalink. The categories are ordered alphabetically. In each group of sub-categories the order will also be alphabetical. (see Manage Categories). The post will still be accessible … Read more

Custom post type permalink structure with the category also acting as an archive

I should have looked a little closer at that link posted. There was a link in that question that contained the answer (https://wordpress.stackexchange.com/a/5313/100538). Below is the code I used to get the effect I need: ///// CUSTOM POST TYPES ///// // register the new post type register_post_type( ‘business’, array( ‘labels’ => array( ‘name’ => __( … Read more

Nice URLs for a Custom Post Type List with a Shared Custom Taxonomy?

For the first preference, you’d need to filter in additional rewrite rules like so; function __extra_country_rewrite_rules( $rules ) { global $wp_rewrite; if ( !isset( $wp_rewrite ) ) $wp_rewrite = new WP_Rewrite; $m1 = $wp_rewrite->preg_index(1); // preg match backreferences $m2 = $wp_rewrite->preg_index(2); $m3 = $wp_rewrite->preg_index(3); $rules[‘country/([^/]+)/([^/]+)s/feed/(feed|rdf|rss|rss2|atom)/?$’] = “index.php?country=$m1&post_type=$m2&feed=$m3”; $rules[‘country/([^/]+)/([^/]+)s/(feed|rdf|rss|rss2|atom)/?$’] = “index.php?country=$m1&post_type=$m2&feed=$m3”; $rules[‘country/([^/]+)/([^/]+)s/page/?([0-9]{1,})/?$’] = “index.php?country=$m1&post_type=$m2&paged=$m3”; $rules[‘country/([^/]+)/([^/]+)s/?$’] = … Read more