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

6
votes
2answers
613 views

Problem with add_rewrite_rule and pagination (paged and page query_vars)

I have a custom taxonomy named location and I want to add sections like 'news' and 'marketplace' for each term, so my url looks like /location/montreal/news/ It works perfectly until I try to add ...
5
votes
1answer
991 views

add_rewrite_rule() vs $wp_rewrite->rules vs 'rewrite_rules_array'?

I've written Rewrite rules for my custom post types. they work well except that WP doesn't update the url in the User Agent when the redirect_url doesn't match the requested_url. everything else ...
4
votes
3answers
886 views

add_rewrite_rule not loading correct page nor getting variables

I've trying to get a showreel title and video id into an URL that can then be accessed by the page. i have the two in the same URL and it either doesn't work or only one comes in. Currently the page ...
4
votes
1answer
349 views

Custom Rewrite Rules Not Sticking

I've written some custom rewrite rules for a special feature on http://www.pewhispanic.org/states/. States is a page with a custom page template, page-states.php. The logic for returning the right ...
3
votes
3answers
247 views

rewrite_rule() not preserving the query string

We have added a custom rewrite_rule to our site to allow for a pretty inbound link to be parsed and handled properly. Links are constructed as domain.com/meetings/faculty/someIDnumber add_action( ...
3
votes
1answer
132 views

Why does wordpress still strip my query var?

Im trying to pass a query var to a custom page template with pretty permalinks. So basically i have a page called "albums". And i want to pass a query var to that page called "type". So the ...
3
votes
2answers
383 views

Custom post type 404s with rewriting even after resetting permalinks

I created a custom post type, of which the (simplified) arguments are: register_post_type( 'Event', 'public' => true, 'rewrite' => array( 'slug' => 'eventy'), 'has_archive' ...
2
votes
1answer
165 views

Custom rewrite rule is not picked by Wordpress

I am trying to create a custom Rewrite URL something like function add_my_rule() { global $wp; $wp->add_query_var('state'); $wp->add_query_var('state_destination'); ...
2
votes
2answers
563 views

Adding meta values to permalink

I have publications and I want to simply add year and month to the permalink. Currently the year and month of publication is added to the post as a meta value. I've set up publications as a custom ...
2
votes
2answers
483 views

add_rewrite_rule and attachment_id

Im trying to add a rewrite rule to make this mysite/?attachment_id=106 view like this mysite/series/106 Ive looked evetywhere in this site and others and its very confuse because there are lots of ...
2
votes
2answers
2k views

Rewrite Rules for Multiple (more than 2) Taxonomies

I am using woocommerce and have some 'product attributes' which are just a taxonomies. I have the following taxonomies: pa_color pa_material pa_style the pa_ stands for product attribute and it ...
2
votes
2answers
225 views

How to change the matches in add_rewrite_rule

One of the examples using add_rewrite_rule function in wordpress is add_rewrite_rule('^nutrition/([^/]*)/([^/]*)/?','index.php?page_id=12&food=$matches[1]&variety=$matches[2]','top'); I can ...
2
votes
1answer
72 views

Add specific word to default page permalink

Right now I am working on one of my client's project. Its all about amazon product display. My client wants me to change the permalinks of all posts, pages, serch results, archive pages, ...
2
votes
2answers
115 views

Rewrite numeric ID parameter for hierarchical custom post type

I've been banging my head against a wall on this one for a while but I'm not quite sure from all the tutorials I read how to see why this isn't doing what I expect. I have a page called ...
2
votes
1answer
92 views

Pagination problem

I have two custom rewrite rules: add_rewrite_rule('foo/bar/?', 'index.php?post_type=foo', 'top'); add_rewrite_rule('foo/bar/([a-z]+)/?', 'index.php?post_type=foo&bar=$matches[1]', 'top'); Which ...
2
votes
1answer
609 views

add_query_vars and add_rewrite_rules

I am looking for some clarity on what add_rewrite_rules does. If I type in, or submit variables from a form, is it supposed to change the query variables to the pretty url? Currently when I type in ...
1
vote
1answer
515 views

Does WP Have a Function To Generate .htaccess RewriteCond?

I know that I can edit .htaccess manually and add a RewriteCond statement inside, but I need to build a plugin that does this the proper way by using WP rewrites which then get pushed into .htaccess ...
1
vote
1answer
50 views

flush_rewrite_rules() cancels the effect of add_rewrite_rule()

As one of my plugin's features, I'm trying to define a custom url structure, like http://www.mysite.tld/foo/{action}. I'm using add_rewrite_rule() along with flush_rewrite_rules() on plugin ...
1
vote
2answers
669 views

Rewrite custom post type url's adding meta box values

I've got these custom post types (CPT) and meta boxes: Movies (CPT) Genre (Meta box) Genres (CPT) If one movie is called Die hard then I want the permalink to be: /genres/action/die-hard This ...
1
vote
2answers
175 views

Make Two Views of Post Type Archive At Two URLs

Updates 6 Feb 14 to make more specific as requested in comments. I have a post type, we'll call it "Projects", with the slug "projects" for which I'd like to offer two views: list view (default) ...
1
vote
1answer
142 views

Custom rewrite rule for backend/admin?

I would like to create a custom rewrite rule that will take the URL: http://domain/submit-project/add but display http://domain/wp/wp-admin/post-new.php?post_type=project Is there any way to do ...
1
vote
2answers
1k views

Fatal error: Call to a member function add_rewrite_tag() on a non-object in /wp-includes/taxonomy.php on line 333

I get this error while trying to load wordpress in a smarty template. But when I visit wordpress I dont get that error any where. the code I use to load wordpress is : {php}include ...
1
vote
1answer
99 views

custom template rewrite

I have a page called my-todo-list and is using a custom page template. The page is accessible via this type of URL : http://domain.com/my-todo-list/ Now I need to paginate it, and I want to look ...
1
vote
1answer
29 views

Custom rewrite_rules - only pass numbers and not alphabetic characters

I'm trying to add a rewrite rule to pass a var to a custom page template. For some weird reason it only excepts numbers in the variables, when I type in characters other then number it directs to ...
1
vote
1answer
27 views

Hooking “delete_option_rewrite_rules” for rewrite rule addition

I'm trying to find the most efficient way to ensure my word press "rewrite rules" are set correctly in the event that another plugin calls the flush_rules() function. Traditionally I've seen ...
1
vote
1answer
68 views

Rewrite rule for admin-ajax.php

I went through a lot of posts and googled a lot, but still couldn't get this to work. I'm trying to create a rewrite rule for admin-ajax.php, to achieve the same results shown here: Adding ...
1
vote
1answer
107 views

Multiple Permalinks for Same Post

I'd like to be able to have multiple permalinks for the same underlying post (for i18n reasons) - eg http://www.example.com/my-custom-post-type/this-is-a-cool-article ...
1
vote
1answer
155 views

How to set up Author archives with sub category URL

So i have a site where i have used the authors.php page so that i can display individual user's profile pages.. the url then looks something like: http://mydomain.com/author/test/ What i would like ...
1
vote
1answer
229 views

Adding paged query to custom URL rewrite

I have set up the following to create 'pretty' post type and category permalinks: function kdev_add_category_rules() { $post_types = array( 'kdev_photos', 'kdev_videos', ...
1
vote
1answer
90 views

Monkey Man Rewrite Analyzer says my rule will trigger but it doesn't [closed]

I installed Monkey Man Rewrite Analyzer, i got a rule installed, it shows in the list, if i test it with monkey man it says it will fire but it doesn't in reality, whats wrong? add_action('init', ...
1
vote
1answer
175 views

Re-write specific custom post type category URL to go to another page

I know this general question has been asked before (like here and here), but the problem is with my limited experience, I cannot get the results I need looking at other people's code. So here's my ...
1
vote
1answer
229 views

resolve /author/ to a page or archive (of all authors) template

I know how to query the users and create a list of authors and can accomplish this in a page template, much like is described here: Authors Page : A page of authors my question is then.... is there ...
1
vote
1answer
530 views

Optimal code for two add_rewrite_rule's

I have two custom rewrite rules; after reading allot of great posts here I found a way to make them work. The question is this: Is there a way to merge this code? I'm not sure that the way I wrote it ...
1
vote
1answer
163 views

Rewrite ugly URL to clean URL

Im trying to go from: http://www.example.com/product?level1=value1&level2=value2&level3=value3&level4=value4 To: http://www.example.com/product/value1/value2/value3/value4 Sometimes ...
1
vote
1answer
236 views

How To Consistently Enforce Rewrite Rule in Plugin Development

Let's say I create a customer support plugin that hijacks the /support part of the URL and redirects it to an MVC framework in my app folder of my plugin folder, like so: RewriteRule ^support(.*)$ ...
1
vote
0answers
23 views

add_rewrite_endpoint() and Custom Post Type Archive

I've got a custom post type. Let's call it books. I'm adding a new rewrite endpoint called pages. I want the url /books/pages/2/ to work but I don't see any rewrite rules generated by WordPress for ...
1
vote
1answer
71 views

Custom query_vars and parse_request on wp-admin

I've read this post http://wordpress.org/support/topic/query-vars-in-admin and although it's quite an old question, it suits me perfectly. I'm trying to accomplish what I already posted here: ...
1
vote
0answers
62 views

WP Rewrite the last two parts of the URL

I have found quite a lot of post on the subject of WP rewrite but I can't find the right words to describe this problem. I'm trying to accomplish the following: ...
1
vote
1answer
43 views

Is a permastruct possible on pages?

Since a couple of weeks I'm trying to create my own rewritings on pages. I read a lot about rewriting with posts and custom post-types. BUT: I have pages that I call with variables. How is it ...
1
vote
0answers
125 views

Get url.com/post_type/taxonomy/term work!

I'm having trouble get what I want by mixing custom post types and taxonomy. I want to run this: www.url.com/post_type/taxonomy/term In my case this: www.url.com/dossier/theme/sante (sante is a term ...
1
vote
0answers
343 views

URL Rewrite and add_query_var not working

I know there are several topics about URL rewriting in Wordpress but none of the topics I found helped me. I want to rewrite the URL profile/?person=abc (which works fine, but isn't pretty) to ...
1
vote
0answers
100 views

How to pass url as a parameter in a add_rewrite_rule

I am building a plugin which relies on passing the url as a GET parameter. Now, I am trying to prettify the links by using rewrite rules but am stuck. What I have now: function ...
1
vote
0answers
132 views

Rewriting single post url; add_rewrite_rule problem?

I have to customize single post permalink (the structure of the permalink) if posts have a certain value in a certain custom fields. I use the filter post_link to change permalink when needed, and ...
1
vote
1answer
124 views

Custom Rewrite Rules

I am developing a plugin, the goal of which is to allow for a bookmark-able, pretty permalink search engine on a single page. To do so, I am using WP's rewrite rules to allow for the ...
1
vote
0answers
49 views

Customise particular RSS permalink

From my old static website, I want to preserve some URLs like the RSS Feed one. My feed URL is http://traduction.bainslesbains.com/actualite-russe.xml and I want to redirect it to the category feed ...
1
vote
1answer
218 views

Need to add rewrite rule that adds in additional information about the post to url

A have a post type for venues which have the attributes title, state, and suburb. Currently using the default WordPress permalinks I get the following format: mysite.com/venue/{title} However, I ...
1
vote
0answers
97 views

What add_rewrite_tag()'s RegEx matches against?

I'm trying to figure out wether I can specify the position of the string to match (i.e. immediately after the domain) to reduce the chances of matching something else, but I don't even know what the ...
1
vote
0answers
143 views

Struggling with add_rewrite_rule

I've read this: Wordpress redirection to get url friendly That led me to this: 1) wp.tutsplus.com/tutorials/creative-coding/the-rewrite-api-the-basics/ 2) ...
1
vote
0answers
119 views

Evaluating a external rewrite rule before internal wordpress rewrite rule

I am been plucking out my hairs since last few days trying to solve this problem: I want to convert my urls from format http://example.com/prodsearch/category/tag1-tag2-tag3-tag4 to ...
1
vote
1answer
89 views

Different rewrite rules for taxonomies and cp in multisite?

I´m making a multilingual site with multisite and I`m wondering if you can specify different rewrite rules for taxonomies and custom posts for the different sites, that are using the same theme. Maybe ...