Stack Exchange Network

Stack Exchange network consists of 175 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

Questions tagged [add-rewrite-rule]

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
21 views

Add slug to default post permalinks ONLY

I've been browsing and reading and testing and can't seem to find a clean solution for my problem. A solution that doesn't affect all other post types, categories, custom taxonomies, etc. :( Is there ...
0
votes
1answer
35 views

Rewrite rules in multisite

I've been trying to set up different rewrite rules on my multisite installation, but as of now, nothing is working. Even the simple add_rewrite_rule('^welcome$', 'index.php?p=1', 'top'); isn't ...
0
votes
0answers
15 views

add_permastruct and wp_rewrite_rule on parent/children posts

So I am looking for a better way or the correct way to rewrite WordPress' url query mydomain?p=123 to show as mydomain/parent/child/ or mydomain/parent/child/gchild I have tried to force change the ...
0
votes
1answer
28 views

add_rewrite_rule wordpress ignoring url pattern, wp rewrite not working

I want to want to make url friendly urls for a custom function I am using in my website. I have added a custom template on my theme dir. The url rewrite function that looks like this: function ...
2
votes
2answers
41 views

Add Rewrite Rule to point to a file on the server

I'm trying to add a rewrite rule that will point to a file inside a plugin. This can be added in the plugin, theme or .htaccess file. My current code from inside the theme's function.php looks like: ...
1
vote
0answers
33 views

Custom rewrite rule sends 404 header on multisite

I have a custom rewrite rule which rewrites /wp-content/themes/my-theme/manifest.json to /index.php?manifest=true. This generates some JSON code for progressive web app functionality, and generally ...
0
votes
1answer
16 views

Wordpress add_rewrite_rule redirection match GET variable not passing through to custom template

My target: Create a page template in theme (page-expert.php) following the guide Page Templates. Create a blank page with the template. The above page will show the profile information for certain ...
3
votes
1answer
45 views

Taxonomy rewrite question

I have custom post types for dining, lodging, and activities. Each of those custom post types uses a custom taxonomy called region. If, for example, I have a region called "downtown", I would like to ...
1
vote
0answers
22 views

add_rewrite_rule redirects if value = 1

I'm currently having a small issue with add_rewrite_rule and can't seem to find any similar issues on stack overflow (even though there seems to be a lot). It works fine for every URL I try: profile/...
2
votes
1answer
53 views

Having trouble with using add_rewrite_rule and pagination

We have a section on the site, such as: www.example.com/for-sale/category-name/ for-sale is a WP page, however category-name is dynamic and is what I wrote the below rewrite rule for. ...
0
votes
0answers
54 views

Custom Post Type parent/child relationship rewrite rules for permalinks

I have been working on this for quite awhile but I'm stuck at rewriting the permalinks for both the parent and the child. So I created two custom post types: magazines and magazine-pages both MUST be ...
1
vote
1answer
27 views

how to add extra GET parameters to post to url with add_rewrite_rule?

I have a blog that has a custom post type article, and the link is http://example.com/article/lorem-ipsum. How can I use add_rewrite_rule to add a new link style to the same post http://example.com/...
0
votes
1answer
31 views

Wordpress add_rewrite_rule with 2 variables

I need to create a rewrite rule that accepts 2 variables. I'm very new to this and am not sure If I'm even on the right track. If there is a better solution to what I'm trying to achieve, I'm open for ...
0
votes
1answer
23 views

Custom permalink question

I have a multisite environment where I am switching databases to retrieve data in a custom post type entered on one site to show on the other site. On the site where the data is not stored (and the ...
0
votes
2answers
28 views

Wordpress pass url to page template when page does not exist

I created a page template to serve information dynamically. For url like example.com/the-hamptons => index.php?page_id=92&filter=the-hamptons For url like example.com/page-that-exists <- ...
0
votes
1answer
22 views

Rewrite rule not working, issue may be in URI request

I'm trying to make a rewrite rule so that posts can be accessed both at the default https://example.com/section1/slug and at https://example.com/prefix/section2/slug. The code below is what I have so ...
0
votes
0answers
51 views

add_rewrite_rule() returns 404 page

I'm using add_rewrite_rule function to add this rule: function custom_rewrite_rules() { add_rewrite_rule( 'category/books/crime', 'category/books/?filter_category=crime', ...
0
votes
0answers
40 views

Rewrite rule not working, suspect redirect string

These rewrite rules are killing me. It is probable something little, but I can't find it. I have a custom post type called 'tournament', it's permalink structure looks like <domain>/<...
0
votes
1answer
84 views

Rewrite Page Parameters

i have a page call "city" http://localhost/wordpress/city/ and it get details from mysql by url id like http://localhost/wordpress/city/?id=paris and i want to change it like http://localhost/...
0
votes
1answer
21 views

add_rewrite_rule() not stored (I think)

I'm developing a plugin that will set up a new custom post type (tournament) and which creates posts for this CPT using an API that gets called using WP Cron. The CPT has a custom field called season ...
1
vote
1answer
39 views

Custom rewrite not working

I'm trying to rewrite URLs on my wordpress site to match Googles "seo friendly" policy. I want to rewrite URL's for 3 types of queries generated from search plugin: a) Location example.com/used-...
0
votes
1answer
36 views

add_rewrite_rule on default post type

I need to add some rewrite rules on my posts in order to have one or more urls for the same post. E.g /foo/post-name and bar/post-name should lead the same post. I'm using this function: function ...
0
votes
0answers
42 views

add_rewrite_rule causes redirect to homepage

I want to create an alias url for my homepage so that it can be accessed at / but also /alias I've set up a rewrite rule but it just causes a redirect to / add_rewrite_rule( '^alias?', '...
1
vote
0answers
36 views

Append query string to all URL's

A user will be directed from a website to a landing page that will have a query string in the URL i.e. www.sitename.com?foo=bar&bar=foo. What I want to do, is then append that query string to all ...
0
votes
0answers
14 views

htaccess redirect multisite

I have a multisite wordpress like monsite.fr and subdomain sub1.monsite.fr sub2.mysite.fr ... I have a booking module "salonbooking" At the click of a button from the booking part of sub1.mysite.com I ...
0
votes
0answers
19 views

Issue with custom rewrite for products and permalinks

Not sure if I've done something incorrectly here, but I have the following rewrite rule; add_rewrite_rule( '^product/([0-9]+)/([^/]+)/?$', 'index.php?name=productl&id=$matches[1]', ...
0
votes
0answers
99 views

add_rewrite_rule not working. Returns 404

I'm adding custom URLs in Wordpress using add_rewrite_rule. Following is my code:- add_action( 'init', 'some_function' ); function some_function(){ global $wp_rewrite; add_rewrite_rule( // ...
0
votes
1answer
36 views

Custom URL routes

I'm a newbie in Wordpress, so excuse me if I ask a noob question. I want to redirect some of the URLs to a specific page (single-deal.php). Now, these set of URLs (regex provided for these URLS) does ...
0
votes
0answers
58 views

Sometimes I am still getting 404 error if I call add_rewrite_endpoint & flush_rewrite_rules on activation / deactivation hook

I need to add a custom tab to my woocommerce my account page, so I followed this article: https://github.com/woocommerce/woocommerce/wiki/Customising-account-page-tabs#creating-new-endpoints /** * ...
0
votes
0answers
28 views

Rewrite url for custom post type with specific url

I have a custom post types called Destinatiosn. These post on click opens as pages and they are organised hierarchically. Example: Malaga Food Gallery Rooms Marbella Food Gallery Rooms Now in ...
0
votes
0answers
21 views

Prefix only some posts with a custom prefix

I'm lost in the world of Wordpress rewrites and I'm hoping someone can help... I'm creating two custom members areas from my site; users logged in as certain roles will be able to view certain posts, ...
0
votes
1answer
34 views

How do I rewrite URL that has custom parameter

I'm stuck on rewriting my url. been searching for days hacking code together but to no avail - So looking for help now. My url is: https://domainname.com/topic/ux-process/?type=newsletter I want ...
0
votes
1answer
51 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
45 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
39 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
1answer
108 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
34 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/(.+?)/?$...
0
votes
1answer
90 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
63 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
19 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
226 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
223 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
32 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
32 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 ...
3
votes
0answers
426 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
200 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
28 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
57 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
19 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' ); ...