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

Filter by
Sorted by
Tagged with
0
votes
1answer
47 views

WordPress add_query_arg from ajax and make url friendly

In WordPress I have set a query arg in ajax like this add_action( 'wp_ajax_get_prepare_link', 'prepare_link'); add_action( 'wp_ajax_nopriv_get_prepare_link', 'prepare_link'); function prepare_link()...
0
votes
0answers
6 views

Rewriting the wp-content but not entirely

This could be tricky question. I need to rewrite the wp-content folder, but not entirely, this means, being able to use an alt path, but still maintaining the full route of wp-content by default For ...
0
votes
0answers
13 views

Add rewrite rule for custom page template

When we add a rewrite rule to create an endpoint and then redirect to a custom template, by default Wordpress sets the body class as a post. Is there any way to create an endpoint without having to ...
0
votes
0answers
21 views

Ugly URLs when there's pagination

My Permanent Link Setting: /%category%/%post_id%.html When there's pagination, the Url looks like this: www.example.com/%category%/%post_id%.html/2 But I want this: www.example.com/%category%/%...
0
votes
0answers
29 views

Custom Taxonomy Rewrite redirects back to home page

I have a custom post type with two taxonomies set. On my Episode CPT I have a rewrite arg set to "rewrite" => array( 'slug' => 'bctv', 'with_front' => false ). Then on my Taxonomy I also have ...
0
votes
0answers
11 views

Page not found on page. How to write a rewrite rule for a custom post type?

add_action('init', 'my_custom_init'); function my_custom_init() { register_taxonomy('manufacturer', ['product'], [ 'labels' => [ 'name' => 'Manufacturer', '...
0
votes
1answer
31 views

Change CPT permalink to use the category

I have a CPT called teachers and a custom taxonomy called teacher type. I'm using the code below to rewrite the url for the CPT and instead of being like: website.com/teachers/post1 it changes the ...
0
votes
0answers
24 views

URL rewrite_rule for GET parameters - Not Working

I want to add custom rewrite rules for my url having GET parameters on homepage e.g http://example.com/?jobs=1 should be http://example.com/jobs/1. Note: Get params can be string as well Well I have ...
0
votes
0answers
21 views

Redirect page to homepage, keeping URL

I'm creating a site where every page is really rendered on a single page - the homepage. I'd like to make it so page URLs - like /about-us/ - redirect back to the homepage, but keep the same URL (/). ...
0
votes
1answer
47 views

rewrite rule not working: redirect to php script if file exists

I wanted to use add_rewrite_rule but had no success. What I want to achieve is that if the URL www.myhomepage.com/custom-media-files/2/screenshot_15_1.jpg is opened, that the user is redirected to a ...
0
votes
1answer
38 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
57 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
17 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
36 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
74 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: ...
2
votes
4answers
179 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
56 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
23 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
58 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
77 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
28 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
35 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
30 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
24 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
53 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
41 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
153 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
43 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
52 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
52 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
52 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
15 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
105 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
39 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
83 views

I get a 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: /** * Flush rewrite rules on plugin activation. */ function my_custom_flush_rewrite_rules() { ...
0
votes
0answers
29 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
24 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
37 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
76 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
47 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
79 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
244 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
41 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
99 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
64 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
22 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 ...