Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

add_rewrite_rule() allows you to specify additional rewrite rules for WordPress. It is most commonly used in conjunction with add_rewrite_tag() (which allows WordPress to recognize custom post/get variables).

0
votes
1answer
9 views

Help adding custom url, rewrite_rules_array

I'm trying to get a rewrite_rules_array rule to work and running into issues. I would like to add a rule so that when someone visits: http://domain.com/product/foo/bar It essentially loads: ...
0
votes
2answers
30 views

URL rewrite problem in WordPress plugin

I am having some trouble getting rewrite rules to work as I want in my a WordPress plugin. I added a rewrite rule: add_rewrite_rule('some_url','some_redirected_url', 'top'); The rule is written to ....
1
vote
1answer
11 views

add_rewrite_rule ignoring other params than the “p” param

A specific post on my website has a shortcode that uses a parameter called "query" to produce its content. So, this is an example of a working URL: https://example.com/my-post?query=980 "my-post" is ...
0
votes
0answers
11 views

How to use add_rewrite_rule() for multi custom post types for same URL structure

I am developing a project in WordPress where I have 2 custom post types book and movie. The owner of this website wants me to make URL structure like the following: Single book URL will be -> example....
0
votes
1answer
12 views

Custom post type with slug for plural (archive) and for single

I've been searching a way to have kind of "two" slugs for a custom post, let me give an example: www.mywebsite.com/articles/ or www.mywebsite.com/articles/page/2/ for the archive www.mywebsite.com/...
0
votes
0answers
25 views

custom rewrite rules will not be added to wordpress rewrite_rules database

I want to make rewrite. this is my rewrite code: function coinDedicatePage_rewrite() { global $wp_rewrite; add_rewrite_tag('%coinName%', '([^&]+)'); add_rewrite_rule('^coin/(.+?)/?$...
-1
votes
0answers
11 views

WordPress Rewrite Rules Causing JavaScript to Not Load

After rewriting URLs for specific page requests, JavaScript is not loading on the pages. There are no 400 errors creating any reason to believe that the paths are being rewritten, but Modernizr is ...
0
votes
1answer
49 views

custom permalink for single post category

Creating a custom permalink for a specific post category. I've got this, and it works great, except, it's performing a redirect, not a rewrite. When viewing The URL bar should still show: example.com/...
1
vote
1answer
50 views

Customize Custom Post Type URL

Actually I needs to change the structure of my urls for the custom post type ( I also want to customise taxonomy url but only targeting post for this question to avoid confusion) My custom post type ...
0
votes
0answers
13 views

Custom rewrites for tabs on a page

I have a Page Template, page-services.php, which displays content in various tabs. The page's URI is currently example.com/services. I want each tab to have its own permalink so that visiting a URI ...
1
vote
0answers
45 views

Rewriting “pretty” blog category URL with htaccess / add_rewrite_rule() causes 404 page

I'm migrating a site between hosts and am having issues with what should be(!) a fairly simple rewrite of a "pretty" URL to display posts filtered by category. domain.xyz/category/cat_name/ => ...
0
votes
1answer
98 views

Custom rewrite for product variation not working

I'm trying to rewrite the product variation url for a Phone Model attribute for example to this url: index.php?product=example&attribute_pa_model=iphone-x This works when I open it in the ...
0
votes
0answers
20 views

WordPress Rewrite Rule to EITHER Match 1 or 2 Taxonomies when adding to URL

I have a custom post type residential using a custom taxonomy residential_taxonomies and I am adding the taxonomy term(s) and the post type name to the url. It works fine if there are always a parent ...
0
votes
1answer
20 views

How to add rewrite rule for product compare page?

I'm trying to create a product compare feature where we can compare three products, Two products must be added while the third is optional. Trying to use the add_rewrite_rule to create a friendly URL ...
2
votes
0answers
177 views

Add parent/child taxonomy to custom post type url

I have seen several cases of one taxonomy being added to a custom post type url, but I have modified that function to include a parent and a child taxonomy term. However, I am getting a 404 when I go ...
1
vote
1answer
62 views

Add rewrite rule to call front-page.php?

I am trying to create a multilanguage website. And I have set my home page to a static page in my WP admin area. This home page ID is 2 and it calls front-page.php template when I am on the home page ...
1
vote
1answer
25 views

Making a custom help center page

I am working now on a new WordPress theme and I want to make a help center system to allow users that will buy my theme do add helper articles. So my plan is: 1- Make a normal new page and create ...
0
votes
0answers
57 views

Manage add_rewrite_rule for woocommerce product single page

I am working on WooCommerce single product post, and I wish to add that post meta at the end of product URL. Like I am managing "product_type" post meta for every product and I want to add this at ...
0
votes
0answers
26 views

Rewrite URL of Specific Post of Custom Type

I'm attempting to implement a rule for a single instance of a post (custom) so that instead of it appearing at mysite.com/post-type/post-title it becomes simply mysite.com/about. I don't want a rule ...
1
vote
0answers
37 views

Pass query vars to front page

I'm trying to pass a query var with a friendly url to the front page but I just get redirected to the front page without var. I use a static page as the front page. If I go to example.com/price I ...
1
vote
1answer
17 views

add_rewrite_rules for type of post

I have the following rewrite rules that are hooked into the init action hook. // This works add_rewrite_rule( '^books/fiction/?', 'index.php?post_type=book&book_type=fiction', 'top' ); ...
0
votes
0answers
18 views

Wordpress rewrite rule remove duplicates

I have a multiple custom post types, one of them being countries and another being activities. I made some URL rewriting so as to change to url to country/activity. It works but now I have the old url ...
1
vote
0answers
32 views

Problem with dinamic add_rewrite_rule()

today i am trying to make a plugin for wordpress that allow change the url of a post to whatever you want, i am added a new custom field called post_permalink_replace in that custom field the user ...
1
vote
1answer
216 views

How to do Basic URL Rewrite Without Redirecting

If I use the simple code below: function my_custom_rewrite_rules() { add_rewrite_rule( '^rewriteme$', 'index.php?page_id=1', 'top' ); } add_action('init', '...
0
votes
1answer
16 views

Tags pages for different Custom Post Types and WooCommerce Products sharing Post Tags

I have these post types : - Articles (blog), - Hotels (custom post type), - Products Activities (WooCommerce products with a product_cat Activities) - Products Transportation (WooCommerce products ...
0
votes
1answer
30 views

Add_rewrite_rule doesn't add custom url in plugin

I'm trying to add a couple of custom urls in my plugin. However, it keeps showing 404 Not Found when I access them. I'm not sure what I've done wrong here. Can somebody show me to the right ...
0
votes
0answers
39 views

How can I use same slug for multiple taxonomies?

I have 3 custom taxonomies for one custom post. For example my custom post name 'project' and three taxonomies are 1. Language and tolls 2. Budgets 3. Locations So we need url for different ...
0
votes
1answer
132 views

Custom Rewrite Rule for Custom Post Type with URL Param

I am trying to create a custom rewrite rule for a custom post type where This: http://test.loc/products/directory/?c=some-value Should become this: http://test.loc/products/directory/some-value ...
0
votes
0answers
55 views

Rewrite CPT permalinks and include WPML language

In my website I am using WPML for translations. So my website's main language is English, and I am rewrite the permalinks of my cpt (artikelen) to website.com/postname/post-id. This works perfectly ...
0
votes
0answers
18 views

Need help to set up a custom rewrite rule for a custom post type

I need help to set up a custom rewrite rule for a custom post type. The actual website URL structure can be any of the following links: https://website.com/android/post-name/?query=string1 https://...
0
votes
0answers
15 views

add_rewrite_rule capture one of a handful of slugs to $matches

I need to capture one of a number of slugs from a rewrite rule. For some reason it is matching, but not capturing the value. add_rewrite_rule( '^work-orders/([^/]*)/amendments/(warp|sir|sr)/([0-...
0
votes
0answers
36 views

Added a prefix in URL permalink structure but the old structure still working!

I have added the prefix /android in the URL structure of my website: https://myandroidy.com I managed to do that by adding the rewrite code below at the end of the function.php However the old ...
0
votes
0answers
49 views

Remove “category” from permalink with add_rewrite_rule

I'am trying to remove the category part from the my category URLs, so that this mydomain/category/knowledge turns into this mydomain/knowledge I want to use add_rewrite_rule on this. Htaccess is ...
0
votes
0answers
19 views

URL Rewrite: Page with term and paged parameter

I'm very rarely using consciously using rewriting so I've got problem ;) I would like have this structure: www.page.com/realizacje/ www.page.com/realizacje/type/[type] www.page.com/realizacje/...
0
votes
1answer
52 views

Custom rewrite url structure for several custom taxonomy (NOT pos_type)

taxonomy type property_city rewrite slug is = property-city taxonomy type property_type rewrite slug is = property-type all this taxonomy is registered for post_type 'property' The current URL ...
1
vote
1answer
33 views

Custom Rewrite rule to match anything not already matched by WordPress

I have these slugs on my website http://www.domain.com/about (standard WP page) http://www.domain.com/custom-slug (not a WP page, post or custom post type) I'm trying to develop a rewrite rule to ...
0
votes
0answers
30 views

Use Custom field in permalink url with single post pagination?

so i have a bit of a bug on my hands. I have created a cpt with a custom field attached and want to display the field in the url structure. It works great, but i also want to split the single post ...
1
vote
1answer
64 views

Have two different URLs show the homepage

I want to have two different URLs for the same page. In particular I want to have a specific URL that shows my frontpage. The URL should be kept however. So these two URLs www.mywebsite.com/ www....
0
votes
0answers
127 views

Usw add_rewrite_rule to display frontpage on specific page

I want to do a very simple rewrite rule, but can't get it to work. I want to have my frontpage displayed, when a specific URL is typed in, like so: www.mydomain.com/mypage should display www.mydomain....
0
votes
2answers
207 views

Exclude single page from permalink rule

I have a page /video which has a javascript app running on it. The javascript reads the url fragments and loads a video. ie /video/my-first will load the video titled My First. My issue here is with ...
0
votes
0answers
40 views

How to use endpoint with pagination in woocommerce

I added endpoint EX: "my_list" like that: add_action('init', 'theme_add_my_account_endpoint'); function theme_add_my_account_endpoint() { add_rewrite_endpoint('my_list', EP_ROOT | EP_PAGES ); ...
2
votes
0answers
232 views

get_query_var with add_rewrite_rule and add_filter('query_vars') not working

I've the following code to rewrite url and get the variable add_rewrite_rule('galeria-de-honra/([0-9]+)/?$', 'index.php?pagename=galeria-de-honra&galeria_year=$matches[1]', 'top'); add_filter('...
0
votes
1answer
106 views

Why isn't my rewrite rule for add_rewrite_rule not working as expected?

I have a post type 'destinations' which should work without the custom post type slug, but it should be hierarchical. So a page like this can exist: /madagascar/grouptrip/information I wanted to creat ...
0
votes
1answer
33 views

Rewrite author URL to example.com/u/{user_id}/{username}/

I want to rewrite the author URL to use the author ID to determine who's page is being displayed, and then automatically add the username after the author ID. The URL should ignore the username to ...
2
votes
1answer
69 views

How to have multiple rewrite endpoints in the same URL?

I'd like to add multiple query_var / value pairs to any URL. For example the base URL of a page is: example.com/nice-page/ I can already achieve one endpoint like (for example, an on-page subgallery)...
2
votes
1answer
49 views

Wordpress Rewrite API calls not creating new rules

I know queries about rewrite rules not working correctly are very common, but in my case I am actually unable to get rules to create in the first place. I need to create a plugin that will be loaded ...
0
votes
0answers
108 views

add_rewrite_rule filter combine 2 conditions/rules

I'm working on a project, where I have implemented custom rewrite rules: add_rewrite_rule('^store/([^/]*)/([^/]*)/([^/]*)/?','index.php?page_id=4&shop=$matches[1]&product_name=$matches[2]&...
0
votes
0answers
82 views

Parent Child Custom Permalink Rewrite Rule for Custom Post Type

Hi I have two custom post types, I am using the parent-child relationship between both like as, store_name (parent) store_offer (child) I want to rewrite the permalink for the both like as sitename....
0
votes
1answer
35 views

Rewrite without query parameter

Currently I'm developing a theme based on Angular 5. Angular exports static assets into a subfolder assets. My development wordpress installation is located in localhost/wordpress. When using the ...
0
votes
0answers
73 views

How to rewrite category URL?

I have two category page layouts. Which layout is shown is controlled by an intro var in the URL. Here's the normal category view/url: mysite.com/my-taxonomy/my-cat-slug/ and here's the "intro" ...