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
20 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
26 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
24 views

Custom Redirect Rule For My Site [closed]

How can i write custom rule for my posts in my wordpress site >> wordpress redirect example.com/?p=123 to example.com/postid123 at default. but i want to write a rule that when a user opens a url like ...
0
votes
1answer
20 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
25 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
21 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
42 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
37 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
31 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
17 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
32 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
0answers
18 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
30 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?', '...
0
votes
0answers
24 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
13 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
18 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
76 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
31 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
44 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
23 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
17 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
32 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
26 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
43 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
27 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
39 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
27 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
75 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
61 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
18 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
167 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
178 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
28 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
335 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
149 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
43 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
18 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
35 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
52 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
455 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
21 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
44 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
66 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
223 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 ...
1
vote
0answers
94 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
20 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-...