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

learn more… | top users | synonyms

0
votes
1answer
17 views

Need help with custom rewrite rule

I have a CPT called presskit, and I need to add a custom query var named welcome_box. I have this code right now: function my_new_url_querystring(){ add_rewrite_tag( '%welcome_box%','([^&]+)' ...
0
votes
0answers
14 views

Stop WordPress from redirecting ?p= in custom rewrite rule to slug of page

I've written a custom rewrite rule, which should rewrite a specific case of a taxonomy url to serve a page. The rule is as follows: add_rewrite_tag('%tax_slug%', '([^&]+)'); ...
2
votes
1answer
19 views

Single Redirection Rule for Pages and Archive links

I am trying to find pretty URL solution for url parameters. Consider this url set http://example.com?token=foo http://example.com/pagename?token=foo http://example.com/parent/childpage?token=foo ...
0
votes
0answers
13 views

Rewrite URL of a page which is child of a Custom Post Type

With the plugin Types I've created a hierarchical custom post type "journeys", and then I set that normal "pages" are child of "journeys". I've created a "journeys" post called "My First Journey". ...
0
votes
0answers
7 views

WordPress Rewrite/Query Var .. ignore a word?

I have created an 'event listing' area on my WP website, it uses rewriting and a query var to dynamically load the event 'slug' as a variable so that I can add pages on the fly. However it has broken ...
0
votes
2answers
25 views

add_rewrite_rule isnt working, not getting added to rules array, why?

I'm trying to add a new rewrite rule but it doesn't seem to be getting added to the array and it certainly isn't working. I'm trying to get this URL, dult.dev/lists/games/destiny, to take me from a ...
0
votes
1answer
25 views

configuration of .htaccess for add_rewrite_rule to make sense

I am trying this code from codex wordpress site function custom_rewrite_basic() { add_rewrite_rule('^leaf/([0-9]+)/?', 'index.php?page_id=$matches[1]', 'top'); } add_action('init', ...
0
votes
0answers
23 views

Widgets: Ajax Filtering and Add rewrite rules

I have built an Ajax filtering plugin for my widgets that works by adding url params through jQuery (when a link is clicked) and having pre_get_posts $_GET these values. These values then setup the ...
0
votes
0answers
14 views

add_rewrite_rule not working on WordPress site

For my WordPress site I am trying to make two URLs display the same content, without redirecting to the other page. So, for example I want to make: ".../books/ilium" display the same content as ...
0
votes
0answers
13 views

using two different urls for same post

I want to use two different permalinks for same post for some reasons the permalink structure i need are http://www.example.com/category-name/post-name http://www.example.com/post-name please help ...
0
votes
0answers
8 views

add_rewrite_rule working for posts but not for pagination

I have used add_rewrite_rule to change my urls please check the code below. add_rewrite_rule( '(.+?)/([^/]+)/?$', 'index.php?category_name=$matches[1]&name=$matches[2]&is_play=1', ...
0
votes
0answers
19 views

I am trying to add a mode rewerite rule that seems to fail

I am trying to redirect everything from /app/.... to a certain page Will use that later for angular js. This is what i came up with : add_rewrite_rule('/app/.*', 'index.php?page_id=11', 'top'); ...
0
votes
0answers
23 views

WordPress render's 404 for known rewrite rule

I have defined rewrite rule for my hieratical custom post type. remove_filter('template_redirect', 'redirect_canonical'); function add_artists_query_vars($aVars) { $aVars[] = "work_index"; ...
0
votes
0answers
16 views

Intermittent Rewrite Problems

I have a few custom rewrites on a site I have developed. I'm having a couple of issues: The rewrites don't work properly without using "flush_rewrite_rules(true)" directly following their setup. It ...
0
votes
1answer
61 views

My add_rewrite_rule is returning a 404

I'm using Nginx and a custom add_rewrite_rule that looks like this: function add_pony() { //this should allow me to POST to domain.com/pony add_rewrite_rule('^pony$', 'index.php?pony=true', ...
0
votes
0answers
14 views

WP Rewrite - some rewrite rules are ignored and instead a redirect is served

I am trying to allow any URI that's prefixed with pf/ to show a page without redirection. I do this by filtering rewrite_rules_array and simply duplicating the rules with a pf/ prefix public function ...
1
vote
1answer
33 views

How to building pretty URLs to reflect category hierarchy?

At the moment, this is how I access brands (custom post type) on my page: http://example.com/<base>/<brand> I would like to access brands like this: ...
0
votes
0answers
21 views

Wordpress add_rewrite_rule with priority

I'm working on a Wordpress website which shows companies in a city. The URL's are like www.address.com/new-york/. I've created a rewrite rule for this and it works but now i'm not able to visit any ...
0
votes
1answer
38 views

How to change the displayed URL?

I'd like URLs like this: http://example.com/root/branch/twig/ be rewritten and displayed to a URL like the one below: http://example.com/root/twig/ At the moment, the two URLs point to the same ...
0
votes
0answers
47 views

Using add_rewrite_rule() to redirect to Front Page

I'm using a static page for my Front page. It is a custom template. On my custom template I am using WP_Query() to show a list of posts. I also have a custom taxonomy called "Types" that I use on my ...
0
votes
0answers
18 views

Custom rewrite rule returns post instead of (start)page

I need a custom rewrite rule so that /a/b/c/d/123 points to the startpage because my own plugin on the startpage needs those parameters from the URL. / I was able to accomplish most of ...
0
votes
0answers
33 views

Trying to add $_POST Array to update_post_meta doesn't populate

This is the code that is sending the info: $postdata = array( 'show_id' => '11', 'show_start' => '2015-03-17 11:00am', 'line_items' => array( '1' => array( ...
0
votes
1answer
45 views

redirect old post type url to new structure url

i have one cpt Anime and it has post_type taxonomy with term anime and animation anime(cpt): (site domain)/anime/post title | |-(tax)Anime |-(tax)Animation And my url structure are ...
0
votes
1answer
31 views

Using category slug in add_rewrite rule

I'm using this function ro rewrite URLs: function archive_rewrite_rules(){ add_rewrite_rule( 'inspiracao/([^/]*)/([0-9]{4})/?$', ...
0
votes
1answer
24 views

Do rewrites added with add_rewrite_rule() persist after plugin deletion?

I am developing a Wordpress plugin and need to ad a rewrite url using add_rewrite_rule(). That does work. But what happens when my plugin is deleted? Does Wordpress cleanup the htaccess or do I need ...
0
votes
0answers
21 views

How to prefix all rewrite rules in wordpress?

I want to prefix all permalinks in wordpress, and get this value from query_args. For example http://wp.dev/sample-page transform in http://wp.dev/en/sample-page. I want for all permalink, for page ...
0
votes
0answers
51 views

RewriteRule directive not working without [P] flag

I need to rewrite some URL's, but I ran into strange problem. For some reason RewriteRule directive only works if I use proxy flag, for example: RewriteRule ^foo$ /www_dev/test/page2-2/ [P] works as ...
0
votes
0answers
44 views

Adding custom post types and add custom add_rewrite_rules

I am adding custom post types using the class created by https://github.com/jjgrainger/wp-custom-post-type-class I am then adding classes using this to add rewrites: /** * Class to init our mvc * ...
0
votes
0answers
33 views

add_rewrite Rule

I want to add a rewrite rule, the remove the "base" from a custom taxonomy link. There current structure is: http://example.com/bundesland/TERMSLUG I would like to have it like this: ...
0
votes
0answers
21 views

Remove rewrite path for custom taxonomy [duplicate]

I want to get rid of the rewrite path for a custom taxonomy. This is the way, I register it: register_taxonomy( 'bl_tax', array( 'stadt'), array( 'label' ...
0
votes
0answers
57 views

$error = 404 after caught add_rewrite_rule

I have a rewrite rule as this to caught old urls from a previous version of the site: add_rewrite_rule( '(ninos|familia|hogar|mujeres|hombres)-[a-z-]+\.php', 'old_id_redirect.php', 'top' ); The ...
0
votes
1answer
60 views

WP redirect rule doesn't work

I'm trying to redirect the page http://www.example.org/newsletter/unsubscribe.html to http://www.example.org/newsletter/unsubscribe. I have tried the following: ...
0
votes
0answers
25 views

Rewrite Rule Regex

I've added rewrite rule: add_rewrite_rule( 'slider-settings/(\w*)$', 'index.php?pagename=slider-settings&slider_id=$matches[1]', 'top' ); This url ...
1
vote
1answer
737 views

add_rewrite_rule() not working

I need to pass a property reference the last part of a URL to search the database for an entry, eg, http://example.com/cottage-details/G638/ I need to pass the G638 into an array for my ...
0
votes
0answers
43 views

Custom rewrite rules without a sub folder path to identify clash with pages

I need to be able to have routes to links that are both pages and products from the main wordpress root directory, without anything to distinguish between what a product (which is a template_redirect) ...
0
votes
1answer
65 views

Rewrite rules and query for virtual page

My question comes from this one. I have never really touched on rewrite rules as frankly, they still do not make sense to me What I have I have successfully build the following link ...
0
votes
1answer
63 views

Custom Post Type with modified permalink structure results in 404

I've defined a custom post type, 'Review', that I'd like to utilize with a custom permalink: /reviews/year/postname. The below code correctly creates the CPT and the custom permalink appears correctly ...
1
vote
1answer
25 views

Best action to call add_rewrite_rule

In Codex I found that the best action to call add_rewrite_rule is the init action. So in this way the function is called every time the site load. But to save the rule in rewrite_rules option it would ...
0
votes
1answer
57 views

Add Custom Pagination Permalink

I'm trying to create a page with multiple loops on it and as such also need multiple pagination. This is proving to be a touch difficult, I've managed to get the links to show correctly by using the ...
0
votes
0answers
46 views

Custom post type url removal for child posts

Hello so my issues is that i cannot figure out how to remove the post type name from the permalink of child post. Already went though most of the solutions on the web but not none helped. Basically ...
0
votes
0answers
45 views

PHP Rewrite Wordpress Folder to act as query string variable throughout site

I'm hoping in this is a possibility with Wordpress and I have been researching this for hours online and I'm not find a definitive or simple working example of how to achieve my goal. I need ...
0
votes
1answer
51 views

add_rewrite_rule with 3 or fewer matches?

I've been reading around a lot on here and Google to do with custom rewrite rules in WordPress and add_rewrite_rule. I found Jan Fabry's answer particularly helpful, but I'm now a bit stuck. I am ...
0
votes
0answers
34 views

Remove final slash from url

I created rewrite this rule: public function manage_user_routes() { add_rewrite_rule( '^user/([^/]+)?', 'index.php?control_action=$matches[1]', 'top' ); } but when I try to access ...
0
votes
0answers
79 views

add_rewrite_rule set up correctly, why does new URL show 404?

My aim is to have the following URL structure: /text-string/text-string/directory/text-string/text-string/1234/ point to page 447 with parts of the URL passed as get variables. (I am not worrying ...
2
votes
1answer
117 views

add_rewrite_rule, plugin activation and plugin deactivation

I see a lot of example showing to call add_rewrite_rule in your init hook, e.g. function add_my_custom_rewrite() { add_rewrite_rule(... } add_action('init', 'add_my_custom_rewrite'); and in ...
0
votes
1answer
154 views

Modifying rewrite rules to use <custom post type>/category/<custom taxonomy term>/

I know I can add a rewrite rule to accomplish this but I'd like to affect the links generated by WordPress (such as when I put a custom taxonomy term into a menu) I have spent the entire day today ...
0
votes
1answer
215 views

Simple page URL rewrite with add_rewrite_rule()

I've check on previous post but my problem seems to not be covered by answers. I have a WP install into a subfolder www.example.com/sub-folder/ and a page password protected ...
0
votes
0answers
179 views

Custom Page Template add_rewrite_rule

I have a custom page in my child theme. I add these code to function.php in my parent theme. In that custom page I have manga reader script. My Custom Page's URL; mangayurdu.com/myy/ ...
0
votes
1answer
35 views

Remove rewrite endpoint on deactivation?

I'm using Milo's answer to add a Rewrite Endpoint as part of my plugin. Is there a straight-forward way to remove a Rewrite Rule upon deactivation? I found this snippet but I'd expect a ...
1
vote
0answers
67 views

How make a multi language routes, with rewrite rules or rewrite endpoints?

I want to know a concept of making a multi language routing system for WP. That is the best practice, to make this routing system with add_rewrite_rules for pages post arhive etc in part, or to use ...