Articles of rewrite tag

How to add custom variable in url without redirect?

I’m trying to add a local variable to my URL. As an example I have this URL: And I want to add ‘en’ variable into it and leave the page working properly: I tried to deal with it using add_rewrite_tag() and add_rewrite_rule() but it isn’t working so what am I doing wrong? add_rewrite_tag(‘%locale%’, […]

Regex in add_rewrite_tag not accepting OR operators?

I am trying to add a custom field to the post permalinks by using a combo of add_rewrite_tag and applying a post_link filter. What I am aiming for is something like this: I can manage to get the %mycustomfield% as %psubject% working by using add_action( ‘init’, ‘register_rewrite_tag’); function register_rewrite_tag() { add_rewrite_tag( ‘%psubject%’, ‘(.*)’ ); […]

custom permalink/shortlink with base62 encoded post ID

I want my post-links to look like /%post_id62%_%postname%/ where %post_id62% is the post ID in base62 encoding (e.g. and my shortlinks to consist of /%post_id62% only (e.g. This is what i’ve got so far (in my functions.php) which obviously doesn’t work: add_action( ‘init’, ‘yoyo_init’ ); function yoyo_init() { add_rewrite_tag( ‘%post_id62%’, ‘([A-Za-z0-9]+)’ ); } […]

Prettified page URL w/ query var redirects to prettified page URL w/o query var

I have a page created (page ID 235) with a page template that will need to be passed a variable. I would like to pass this variable through the URL. My first attempt was to pass this with a GET variable, and that worked just fine. URL: Now, I thought I’d spice this up […]

Permalinks, Rewrites, Get Variables, Oh My!

Ok, so I know it’s a silly title, but it’s exactly how I feel right now.. I’ve created some custom rewrites for WordPress and they work great, the only problem is that now I need to add pagination. My rules are messing with the pagination and vice versa. The page url will update when I […]

Multiple values in a rewrite rule, is it possible?

I’m using url rewrites for a filter i’m building. The current solution works for one selected value. So if I select one type of dish like dinner, it goes to /recipes/dinner/. But what if I want to filter on dinner and lunch? Is this possible, with the add_rewrite_rule? The current solution is as followed. add_filter( […]

How to filter custom post type archive by meta value

I have a problem where I’m trying to build a calendar plugin for a client. I’m having trouble getting a date based archive for the custom post type I’m using. I’m not too well versed in how the wordpress system for handling permalinks is set up on a low level, and I’ve hit a wall. […]

Rewrite Rules for Multiple (more than 2) Taxonomies

I am using woocommerce and have some ‘product attributes’ which are just a taxonomies. I have the following taxonomies: pa_color pa_material pa_style the pa_ stands for product attribute and it is built-in to WooCommerce handles these taxonomies, so I can’t change that. WooCommerce also comes with product categories (product_cat) and product tags (product_tag) taxonomies. the […]

Using the Rewrite API to Construct a RESTful URL

I’m trying to generate rewrite rules for a RESTful API. I just want to see if there is a better way to make this work than having to write out every possible rewrite combination. Ok so I have 4 query variables to account for in the URL Indicator Country Response Survey The base url will […]