Ecommerce Shopify WordPress Discussion

WordPress URL rewriting; How to match URL parameters

I have URL: https://www.example.com/articles?page=2. I need to rewrite it to WordPress format: https://www.example.com/index.php?category_name=articles&paged=2. I tried with rewrite rule like this: add_rewrite_rule('^(.+?)\?page=([0-9]+)$', 'index.php?category_name=$matches[1]&paged=$matches[2]', 'top'); However this does not work. I have legacy CMS that I try to migrate to WP and I need to keep old URL structure. Suggestions?
First, you need to register your custom query variable using add_rewrite_tag. Add this to your theme's functions.php file or a custom plugin: function custom_rewrite_tags() { add_rewrite_tag('%my_page%', '([^&]+)'); } add_action('init', 'custom_rewrite_tags'); second, define your custom rewrite rule using add_rewrite_rule in functions.php file function custom_rewrite_rules() { add_rewrite_rule('^articles/([^/]+)/?$','index.php?category_name=$matches[1]&my_page=1','top'); } add_action('init', 'custom_rewrite_rules'); After making this changes, you need to flush the rewrite rules. You can do this by visiting the Settings > Permalinks page in your WordPress admin and clicking the Save button. This action refreshes the rewrite rules.

January 20, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.