Permalinks, Rewrites, Get Variables, Oh My!

I’m not sure but I think that you just need to add two query vars, “group” and “value”, not two rewrite tags. Can you try this: add_filter(‘query_vars’, ‘cyb_add_query_vars’); function cyb_add_query_vars( $vars) { $vars[] = “group”; // name of the var as seen in the query string and URL $vars[] = “value”; return $vars; } add_action(‘init’,’cyb_add_rewrite_rules’); … Read more

Rewrite WordPress Custom URL

WordPress has its own system managing redirects and page routes, you don’t need to edit the .htaccess file. You’ll want to start with the function add_rewrite_rule(). It takes 3 arguments: route (as regex) query vars priority So first, you need to find out the query vars of account/customer-bookings/. If it is a page, it can … Read more

Custom rewrite rule for backend/admin?

In general, it is possible, but you need to define ADMIN_COOKIE_PATH in your wp-config.php to the value / which might cause security issues. First of all define this rewrite rules in your .htaccess right before the rewrite rule of wordpress: # Make sure, there is a trailing slash RewriteRule ^submit-project/add$ submit-project/add/ [R=301,L] # mask the … Read more

Removing the post format (type) slug

In your last code example, you’re returning a wrong type for the post_format_rewrite_base. It should be a string, not an array. However, your idea goes in the right direction. You have to take care about all the «routes» that are implied by the default rewrite rules, WordPress creates for post formats: type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ => index.php?post_format=$matches[1]&feed=$matches[2] type/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ … Read more

Custom URL for each product variation – rewrite rules

Ok, for anyone looking for this, here’s a complete plugin that I came up with, that solves the issue: <?php /* Plugin Name: WooCommerce Variations URL Description: Adds support for variation-specific URL’s for WooCommerce product variations Author: Václav Greif Version: 1.0 Author URI: https://wp-programator.cz */ namespace WCVariationsUrl; final class Init { /** * Call this … Read more

Add Rewrite Rule to point to a file on the server

(Revised answer) Don’t call flush_rewrite_rules() on init. Instead, if you want to do it programmatically, call the function from your plugin or theme activation function. If you’re not doing it programmatically, you could simply visit the Permalink Settings page (Settings → Permalinks on the WordPress back-end). WordPress does support adding a rewrite rule that doesn’t … Read more

Rewrite url for existing page without flush_rewrite_rules

If you want to rewrite example.com/test123 (a standard WordPress Page) to example.com/test234 (another standard WordPress Page) without having to save the rewrite rules in the database, then one option is using the request filter hook: add_filter( ‘request’, function ( $query_vars ) { if ( isset( $query_vars[‘pagename’] ) ) { $slug = $query_vars[‘pagename’]; // Define a … Read more