Rewrite rules modify a web URL's appearance. This modification is called URL rewriting. Rewritten URLs (sometimes known as short, fancy URLs, search engine friendly - SEF URLs, or slugs) are used to provide shorter and more relevant-looking links to web pages. The technique adds a layer of ...

learn more… | top users | synonyms

26
votes
1answer
22k views

Need help with add_rewrite_rule

SOLUTION I've gone with Update 3 and have got it working. What I had misunderstood, was that I believed that a rewrite rule would change designers/?designer=some-designer&bid=9 to ...
18
votes
8answers
15k views

How do you create a “virtual” page in WordPress

I'm trying to create a custom API endpoint in WordPress, and I need to redirect requests to a virtual page in the root of WordPress to an actual page that ships with my plug-in. So basically, all ...
13
votes
1answer
3k views

When should add_rewrite_tag() be used?

I've spent a few days trying to learn how to best add rewrite rules. So far my understanding is that a suitable way to add simple rules is to use add_rewrite_rules(), with large thanks to Jan Fabry on ...
11
votes
1answer
15k views

How to create custom URL routes?

I have a very peculiar requirement, hopefully I can explain it without being too confusing. I created a page template where I list some properties I get from an external XML file, so far no problems, ...
8
votes
3answers
5k views

WordPress Rewrite Rules for Custom Post Type and Taxonomy

I have found this place to be a good source of information in the past through a lot of Googling for the problems I have run into. My question pertains to the verbose rewrite rules WordPress uses. I ...
7
votes
3answers
1k views

Can't get a custom template taxonomy page to display

I've been trying to wade my way through learning the ins and outs of taxonomies and how to integrate them into themes and I've run into a pretty basic issue that I can't seem to figure out. I started ...
6
votes
0answers
790 views

add_rewrite_endpoint() not working for custom post type archives [closed]

i'm working on somekind of wiki/encyclopedia system based on wordpress. there are two custom post types. i'll show my configuration for one of them: $labels = array( 'name' => _x('Objects', ...
5
votes
2answers
4k views

Change the “page” slug in pagination

Simple question. When pagination is activated, the URL changes to "site.com/page/2". For my site, this should be "site.com/paggetto/2". How can I change that rewrite rule? I also want to change ...
5
votes
1answer
432 views

CPT Template Not Showing - Getting 404

I'm developing a Custom Post Type plugin, which works fine in dev. Now that I've moved it to production, I'm getting a 404 when I try to display the template for the CPT. So, two questions: 1- Is ...
5
votes
1answer
2k views

Rewrite Rule for Multilingual Website, Like qTranslate?

I would like to write my own little plugin for language switching. For that, the very first thing would be to get the rewrite rules running. I have been looking around the web for 2 hours, but I ...
5
votes
1answer
1k 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 ...
5
votes
1answer
673 views

Rewrite rule for Custom post type Monthly and Yearly archive

I have a custom post type "contest_recipe". I can view contest recipe posts by year and by date with the following urls: http://example.com/2011/?post_type=contest_recipe - shows all 2011 contest ...
5
votes
3answers
790 views

How-to add rewrite rules to point the uploads folder to a subdomain

The goal Point the upload-folder to a static subdomain to serve adaptive images, that can get cached. WordPress Rewrite Rules You can read more in detail about rewrite rules API at Christopher Davis ...
4
votes
1answer
746 views

add_rewrite_rule not producing anything in $_GET

Trying to get pretty permalinks happening for a plugin that displays events I have this: function my_add_rewrite_rules() { global $wpdb; $org_options = get_option('event_settings'); // ...
4
votes
1answer
828 views

How Do I add a redirect rule to Wordpress?

Right now, I'm able to dynamically generate js and css, based on my theme options To do that i set up a query var, that if present redirects to a php file, which then loads itself as a javascript ...
4
votes
2answers
526 views

Preserving $_GET parameter while using custom Rewrite Rule

This third party add-on plugin for Gravity Forms allows you to edit existing posts via the front end when you embed a form in your chosen template. All you need to do is append the GET ...
4
votes
1answer
188 views

Permalinks so that one custom post type appears to be a child of another, not working

Currently I have two post types, "products" and "products-data" they are separate post types; however, for all intents and purposes products-data is a child post of products. The relation is ...
4
votes
3answers
590 views

How to add a custom URL placeholder to author archives?

I am working with a client who has a directory site that allows users to create accounts, then lists of items from the directory. Right now, whenever a user creates an account, she gets a profile URL ...
4
votes
1answer
433 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 ...
4
votes
1answer
2k views

Querystring parameter getting lost in rewrite rule

I have successfully added a custom post type and the permalink structure works great. So, for instance, I've got a custom post type books, and the permalink to a book is /books/the-dictionary. My ...
4
votes
2answers
660 views

Rewrite url for custom post type

I'm using WPML plugin to translate my site. I have a custom post type called "vinos" and I use this args: $args = array( 'labels' => $labels, 'hierarchical' => false, ...
3
votes
3answers
296 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
3answers
2k views

Need help with friendly URL's in Wordpress

I'm creating som custom templates in Wordpress and I'm passing some data in the URL's. Currently my URL looks like this: http://www.mysite.com/designers/?id=43&name=designer+name The URL ...
3
votes
3answers
2k views

Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?

I am having a bit of a strange issue with rewrite rules not flushing properly. I have tried using flush_rewrite_rules(); and flush_rewrite_rules(true);. I have also tried globalizing $wp_rewrite ...
3
votes
3answers
3k views

Need help with rewrite_rules_array

I have a page that I access at /category/tasks and the file is located at wp-content/themes/my-theme/tasks.php. I would like to make it so I can add a flag after tasks and pick up the query strong in ...
3
votes
1answer
4k views

Add Rewrite Rule for custom page

Was trying to create author specific page with author specific URL and it was working fine,but when i created this URL did not taken in to account following 2 factors Author Name Conflict (similar ...
3
votes
3answers
728 views

Plugin to Consume a Web Service

I'm attempting to write a knowledge base plugin to consume the Salesforce API and pull in solutions in a RESTful style application path; however, some of the core plugin concepts escape me. For ...
3
votes
1answer
553 views

How do you permanently remove default rewrite rules from the wp_options table?

We have tons of rewrite rules saved in our wp_options table and I'd like to permanently remove any entries that we're not using on our site (such as comment feeds, page attachments, etc.). What's the ...
3
votes
1answer
1k views

How to add custom rewrite rule to .htaccess?

I want to add a custom rewrite rule to my .htaccess file using a function inside functions.php The rewrite rule I want to add is as follows: RedirectMatch 301 ^/author/(.+)$ http://name-blog.com/$1 ...
3
votes
1answer
130 views

Prepend meta_value to permalink of post

I have 2 custom post types movies (non-hierarchical) and series(hierarchical). Each post from seriestype has a meta field _movie which contains a movie ID. I want to specify a custom permalink ...
3
votes
1answer
52 views

Blog installed in subdirectory but need to create pages in root. How to use permalinks?

Our companies blog is installed in /blog. Our permalink structure is /%postname%/ so posts currently look like https://www.domain.com/blog/post We've been asked to publish a series of guides which ...
3
votes
2answers
474 views

Make post slug have priority over category slug

I have a wordpress site where the category base is stripped from the url. Now, when a category has a certain slug that's similar to a post slug, the category is shown. I would like to show the post ...
3
votes
1answer
570 views

Modify custom post type rewrite rules in a separate function

I want to modify the rewrite rules for a custom post type, tribe_events, which is registered as a post type within "The Events Calendar" core plugin files (the-events-calendar.class line 24): ...
3
votes
2answers
2k views

Clean URLs for custom $_GET variables

I have a query var show=othertemplate that I can add to any URL to show any post, page or archive in Wordpress in a different template, like this: mysite.com/[any URL]/?show=othertemplate. I'd like ...
3
votes
2answers
460 views

How to use Post Custom Metadata in Post Titles and Post Permalinks

I am very new to WordPress. How can I use post custom metadata in place of Post Titles, and as the Post Permalink? For example, instead of domain.com/the-post-title, the permalink would be ...
3
votes
1answer
607 views

WordPress Network on IIS7/SQL Server - Rewrite Issues

I've just installed a fresh WordPress setup on Windows Server 2008 Web R2 (IIS7) with SQL Server Express and WordPress 3.1. I completed the install successfully and logged into the admin section to ...
3
votes
2answers
477 views

wp_insert_post breaks rewrite rules

I'm using wp_insert_post to programmatically add content to a site. This works fine with posts, categories and tags, but not with pages. When I attempt to add a page (i.e. post with post_type=page), ...
3
votes
1answer
248 views

Custom comments

I'm trying to create a custom comments page with pagination. I have non-hierarchical custom type "apartments". It makes urls like: /apartments/ - for acrhive /apartments/%id%/ - for post page ...
3
votes
1answer
231 views

WordPress Custom URL Rewrites

I am trying to add a custom rewrite rule with a single variable to a specific page. The 'ugly' version is http://example.com/used-cars/car/?carname=name-of-car and the 'pretty' version I'm going for ...
3
votes
0answers
421 views

How do I rename the wp-admin folder with the admin_url filter? [duplicate]

Possible Duplicate: Can I rename the wp-admin folder? I have applied some mod_rewrite rules to redirect /wp-admin to /my-admin - based on this tutorial. I also changed the admin url ...
3
votes
0answers
63 views

Add /demo/ slug with rewrite rule [duplicate]

Possible Duplicate: Add extra parameters after permalink? I need to add a slug to every post. Current permalinks http://www.my-domain.com/2012/01/01/my-post-title/ or ...
3
votes
5answers
5k views

URL Rewrite + Page + Custom Post Type = Unusual Redirect

Yet another URL rewrite issue :) The Problem I have a URL rewrite rule that should work, but against all logic it redirects without passing the query var. The Juicy Details The site has a page ...
3
votes
1answer
265 views

Help with a TV series Rewrite structure

Not sure if this is possible, but bear with me. I think I am halfway there. First a little background: I'm using the build in hierarchy in WordPress to form relationships between post types. I ...
2
votes
1answer
3k views

Custom post type permalink endpoint

I have a custom post type called "destinations" and I have set the EP mask for the post type to default EP_PERMALINK. I have added a couple of endpoints as follows : add_filter( 'query_vars', ...
2
votes
2answers
1k views

How to trigger 404 for custom query var?

How can you trigger a 404 when using custom query vars? I've got re-write rules written for a custom query var, but if you were to request a URL for the query var that should technically be a 404 it ...
2
votes
1answer
5k views

Custom page with variables in url. Nice url with add_rewrite_rule

Using WP3.1 I Have a custom page with a WP_Query and the query gets dynamic variables from the url. And i want safe variables and clean urls. Example: ...
2
votes
2answers
896 views

Preventing index.php?category_name=something from redirecting

I'm trying to filter posts in a category by the year of the post's date. I also want to do this without being redirected to the year template so my ideal URL would be ...
2
votes
1answer
625 views

Change the Permalink for wordpress attachment

My attachments are currently rewritten from http://localhost/?attachment_id=3 to http://localhost/images/image-title using @Bainternet's answer here. $new_rules['images/(\d*)$'] = ...
2
votes
2answers
4k views

How to modify URL structures in custom post types and taxonomies or terms

I am well aware that there are several posts covering the topic of customizing the permalink URL structure of custom post types, custom taxonomies, and taxonomy terms. However, none of them are real ...
2
votes
3answers
917 views

How to add .htaccess code through a function?

I need to add the following .htaccess code through a function <IfModule mod_deflate.c> # Insert filters AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html ...