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

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).

1
vote
1answer
18 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
13 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
12 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
22 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
12 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
16 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
35 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
28 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
17 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
16 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
30 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
14 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
41 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
22 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
20 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/(.+?)/?$...
0
votes
1answer
54 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
59 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
101 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
139 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
25 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
276 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
97 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
27 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
39 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
26 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
37 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
317 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
19 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
36 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
49 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
192 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
80 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
19 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
39 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
65 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
22 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
57 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
36 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
32 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
65 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
159 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
247 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
53 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 ); ...