Change author base slug for different roles

In your example, the author rewrite pattern changes from /author/[authorname]/ to /[author_level]/[author_name]/. If we allow [author_level] to be anything, we will get into conflict with the rules for pages, because /[anything]/[anything]/ can be either an author archive or a regular subpage. For this reason, my solution assumes you have a limited number of author levels, … Read more

Rewrite Slug for CPT Archive Pages to Plural Name of Slug

When you register the post type, set the argument ‘has_archive’ to a string, in your case plugins. The doc block for register_post_type() says: @type bool|string $has_archive Whether there should be post type archives, or if a string, the archive slug to use. Will generate the proper rewrite rules if $rewrite is enabled. Default false. Minified … Read more

web.config conflict on IIS

I don’t have the reputation to comment so I’m sure this may be dumped if not totally complete/accurate; but, doesn’t WP work in a way that it goes through the core’s index.php file using rewrites and such. This being the case, if you don’t specify a specific file that you are accessing, you aren’t really … Read more

Add .html (dot HTML) extension to custom post types

This seem to work: Create the rewrite rules like post-type/post-name.html. You can use arrays to create the rules for just some set of post types instead of doing it for all of them. add_action( ‘rewrite_rules_array’, ‘rewrite_rules’ ); function rewrite_rules( $rules ) { $new_rules = array(); foreach ( get_post_types() as $t ) $new_rules[ $t . ‘/([^/]+)\.html$’ … Read more

Permalink format: singular or plural

There’s a simple rule that I follow (it’s hard to explain, so I’ll give examples): http://example.com/categories/ <– This plural form should mean that the page shows a list of all the categories in use on your site. Similarly, if it’s “authors” (as in http://example.com/authors/), I’d expect the page to show a list (with or without … Read more

Remove custom post type slug from URL

That’s how you can do first part of the job – get rid o CPT slug in post link (eg. news post type). function df_custom_post_type_link( $post_link, $id = 0 ) { $post = get_post($id); if ( is_wp_error($post) || ‘news’ != $post->post_type || empty($post->post_name) ) return $post_link; return home_url(user_trailingslashit( “$post->post_name” )); } add_filter( ‘post_type_link’, ‘df_custom_post_type_link’ , … Read more

Understanding add_rewrite_rule

A basic rule that would work for your example: function wpd_foo_rewrite_rule() { add_rewrite_rule( ‘^foo/([^/]*)/?’, ‘index.php?pagename=$matches[1]&param=foo’, ‘top’ ); } add_action( ‘init’, ‘wpd_foo_rewrite_rule’ ); This takes whatever comes after foo/ and sets that as pagename for the query, and then param gets the static value foo. If you need different URL patterns, you’ll need extra rules for … Read more