Two (or more) parallel (sub-)TLDs that are retained when surfing the site / dynamically set the site address?

You could filter the option requests for the host. In your wp-config.php below the line … require_once ABSPATH . ‘wp-settings.php’; … add the following lines: add_filter( ‘pre_option_home’, ‘set_current_host’ ); add_filter( ‘pre_option_siteurl’, ‘set_current_host’ ); function set_current_host() { return ‘http://’ . $_SERVER[‘HTTP_HOST’]; } add_filter() is not available earlier, and you should keep such code in your wp-config.php. … Read more

Masking wp-content/themes/name/images to just images directory using htaccess

Check out the Roots WordPress Theme. They seem to do exactly what you want with the URLs. Here’s a snippet from their roots-htaccess.php file: add_action( ‘generate_rewrite_rules’, ‘roots_add_rewrites’ ); function roots_add_rewrites($content) { $theme_name = next( explode( ‘/themes/’, get_stylesheet_directory() ) ); global $wp_rewrite; $roots_new_non_wp_rules = array( ‘css/(.*)’ => ‘wp-content/themes/’ . $theme_name . ‘/css/$1’, ‘js/(.*)’ => ‘wp-content/themes/’ . … Read more

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

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

Change the “page” slug in pagination

For some sites in German I use the following plugin to translate page to seite (the German word for page): <?php # -*- coding: utf-8 -*- /** * Plugin Name: T5 Page to Seite * Description: Ersetzt <code>/page/</code> durch <code>/seite/</code>. * Author: Fuxia Scholz * License: MIT * License URI: http://www.opensource.org/licenses/mit-license.php */ if ( ! … Read more

Does WordPress keep track of a post’s URL history and provide automatic redirects?

Does WP keep track of a posts url history, providing rewrites/redirects for former urls? Yes it does. If you change a post slug, wordpress 301 redirects the old to the new URL (if your server setup allows it). Any light on how WP handles this would be appreciated. Unfortunately, I’ve never seen this feature properly … Read more