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
19 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
13 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
15 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
9 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
7 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
33 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
0answers
47 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
38 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
33 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
47 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
16 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
31 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 ...
0
votes
0answers
17 views

How write rewrite rule to reroute tiny url?

I want to know how to write a regex : for exemple url: http://localhost/wordpress/post-title/lang/en become http://localhost/wordpress/post-title/en. I need a global rule for all types of posts? ...
0
votes
1answer
53 views

add_rewrite_endpoint not working

I've been having looot of troubles with this function, I don't know what to do, because I tried everything. I have a custom post type, let's call it study. The url structure for it is ...
0
votes
0answers
35 views

register_post_type, add_meta_box, add_rewrite_rule

I'm working on custom post type with some custom fields setup using add_meta_box. register_post_type("sample"); add_meta_box("sample_type"); add_meta_box("sample_brand"); I want to get it working ...
1
vote
1answer
71 views

generate_rewrite_rules (action) vs add_rewrite_rule (function): which one is preferred?

I see these two methods can be used to create new custom rewrite rule, so under what situation which one is preferred? I suppose they are doing the same thing? I can either use: add_action( ...
0
votes
1answer
26 views

add_rewrite_rule issues

i usually add rewrite rules for custom pages like this: add_rewrite_rule('^deal-purchase?','index.php?is_purchase_page=1&post_type=page','top'); However on a site im working on now, the above ...
0
votes
0answers
23 views

Prevent guessing slug

I have the following rewrite rule function add_rewrite_rules($rules) { $new_rules = array( 'buscador-latte/(.*)/?$' => 'index.php?page_id=866&search_parameters=$matches[1]', ); ...
0
votes
0answers
16 views

Rewrite Rule To Own File

Is it possible to add a rewrite rule to redirect to a page other than index.php? For example: add_rewrite_rule('([^/]*)/preview/?','preview.php?page_title=$matches[1]','top'); The above code only ...
1
vote
0answers
60 views

Rewrite rule for path of favicon.ico ( Add_rewrite_rule function possible ? )

Hi Wordpress developers ! I'm wondering, is it possible to make by PHP and power of Wordpress following: If user access http://localhost/favicon.ico, is it possible to make show user data from ...
0
votes
0answers
21 views

Wordpress internally rewrite rule challenge

Questions 1: I work on wordpress website for a client. But the client like to have a deep level url structure. The custom post type can be from level 1 to unlimited levels in the url structure. ...
0
votes
0answers
48 views

htaccess url rewrite within WP installation

I want to use one of my subdomains to rewrite urls and finally forward to an origin extern domain. Example: goto.mydomain.com/1saKCA3 -> externdomain.com/1saKCA3 I already tried to implement the ...
0
votes
1answer
16 views

Rewrite URL to plugin file

I'm creating a plugin that handles courses from a 3rd party system, I've created a add_rewrite_rule() so the url /course/32567 rewrites to /wp-content/plugins/course-plugin/course-page.php?code=32567 ...
0
votes
0answers
20 views

Remove add_rewrite_rule from the init hook

I have some pretty complex way to calculate a rewrite rule. Normally I add them like this function my_rewrite_rules(){ //fancy stuff to calculate the $rewriteurl which takes some time to ...
0
votes
2answers
130 views

What is wrong with my rewrite rule for a page URL with query parameters and short codes?

I'm new to WP programming and I am having trouble with what would be a simple problem in other environments. I created a page (cdl-manual) using the normal WP admin UI. Then I added some functions to ...
2
votes
1answer
79 views

Can someone explain the function of the third parameter of “add_rewrite_tag”

Can you please explain the third function parameter queryreplace of add_rewrite_tag. Explanation with code examples will be much appreciated. UPDATE i wrote this code below to make a page with slug ...
1
vote
1answer
69 views

add_rewrite_rule - working fine but broken for pagination

My setup is as follows: Taxonomy called 'region' Terms in this taxonomy like 'scotland' Various post types that use this single taxonomy I have achieved functioning pretty permalinks of the ...
0
votes
2answers
31 views

How can I set up a secondary permalink structure?

So I have a situation on a site where I need multiple permalink structures. Now, I already know what you're going to say because literally every Google and SX result I've looked through says the same ...
0
votes
1answer
37 views

Rewrite rule not passing variable

I have the following code in my functions.php file, and it simply will not work to return the value passed via the URL. This is the code below: function custom_url_source() { ...
2
votes
2answers
276 views

Custom pages with plugin

I'm developing some plugin where I would like to enable custom pages. In my case some custom page would contain a form like contact form (not literally). When user will fill out this form and send it, ...
0
votes
1answer
76 views

add_rewrite_rule on multisite doesn't work

I define a rewrite rule on an init hook like: add_rewrite_rule( 'foobar/(abc|def|ghi)/(.+)(/(\d.+))', 'index.php?my_action=$matches[1]&my_name=$matches[2]&my_version=$matches[4]', 'top'); ...
2
votes
2answers
59 views

different child theme for subdomain

I've got a site that I'm trying figure out how to apply different child themes to based on a subdomain. Applying the child themes shouldn't be difficult, it's more the .htaccess magic that I'm a bit ...
0
votes
0answers
25 views

I want to add one extra field to my URLs, I'm using Rewrite functions but it doesn't work

I think my question isn't in the right way, I just ask it. I want this routings for my wordpress site (for example in Custom PostType Archive page): example.com/VALUE => ...
0
votes
0answers
49 views

Remove Rewrite Rule

after adding a rule: add_action( 'init', 'wpse26388_rewrites_init' ); function wpse26388_rewrites_init(){ add_rewrite_rule( 'usuario/([0-9]+)/?$', ...
0
votes
0answers
24 views

Rewrite pages and custom post type

I created a post type named soft_drink with a rewrite rule of /my_soft_drinks/%soft_drink%. my_soft_drinks is also a page slug. In my menu structure has the page soft_drinks parent submenu items. When ...
2
votes
1answer
75 views

Permalinks, Rewrites, Get Variables, Oh My!

Ok, so I know it's a silly title, but it's exactly how I feel right now.. I've created some custom rewrites for WordPress and they work great, the only problem is that now I need to add pagination. ...
0
votes
1answer
53 views

Create custom permalinks to show Custom Post Type's relationship?

I'm creating a WordPress site that has 3 custom post types registered: course, chapter, and lesson. All of these post types are inter-connected and share a relationship using custom fields. For ...
0
votes
0answers
22 views

URL mod rewriting for my custom links

My Actual link :- http://nanhai.com/nanhai-overview/162/ I want it like :- http://nanhai.com/nanhai-overview/xyz/ My code add_action('init', 'add_actor_url'); function add_actor_url() { ...
0
votes
1answer
102 views

Custom post types and custom variables — add_rewrite_tag() not working

I have spent a whole day trying to resolve in issue. I'm trying to retrieve a custom varaible which is added by my plugin. I have tried testing the regex using the rewrite analyzer, which recognizes ...
0
votes
0answers
37 views

Rewrite Rule Not Working

I am trying to use a rewrite rule to get 3 variables from the URL. Here is my rule: add_action( 'init', 'pe_rewrite' ); function pe_rewrite(){ add_rewrite_rule( ...
0
votes
0answers
206 views

URL rewrite custom taxonomy using add_rewrite_rule() or generate_rewrite_rules()

I'm trying to get my head around amending some URL's for a website I have created. After reading two (very informative) answers (1, 2) but I'm still a little unsure how to approach creating a URL that ...
0
votes
0answers
37 views

Set a Category As My Homepage using add_rewrite_rule

When someone visits the homepage of my wordpress site: http://www.mysite.com/wordpress/ I want them to see the contents of this page: http://www.mysite.com/wordpress/category/cars/ Attempt # 1: ...
0
votes
0answers
15 views

how to change some of the rules in the database

I need to add a rewrite rule for a WP page. I noticed that the rule is already part of the existing set, but apparently it is not correct. With the hope some internal mechanism would have replaced ...
0
votes
0answers
44 views

Help with add_rewrite_rule solution

In my Wordpress blog, I configured permalinks > Category base to "magazine" with links having this format: http://www.mydomain.com/magazine/news/europe/france The above link opens the France ...
0
votes
2answers
38 views

Rewrite for page with a possible unknown parent page

I am trying to add a wp rewrite for my plugin that allows users to include a shortcode on a page that will then display a calendar. This calendar then requires url params in order to navigate the ...
0
votes
0answers
26 views

Rewriting URLs with Query Strings

I've been (unsuccessfully) attempting to prettify some URLs in a website I'm building in Wordpress, from something like this - ...
0
votes
0answers
37 views

URL rewriting with custom pagination

I'm using a custom query to display the results with the pagination and rewrite the URLs. The following function works fine and displays the URLs in following pattern: ...
0
votes
1answer
71 views

rewrite rules social share links

Within the Ultimatum's theme childtheme.php I've added rewrite rules to the rewrite rules and it works perfectly fine. However, it does not work if the URL is shared in Facebook or Twitter. The ...
0
votes
0answers
50 views

add_rewrite_rule works only with one “directory”

This works (Wordpress redirects to the canonical URL of the post with the given slug): add_rewrite_rule('mydir/([^/]+)/?$', 'index.php?pagename=$matches[1]', 'top'); This is not working (404) ...
0
votes
0answers
35 views

How can i add a rewrite rule in wordpress

I want to add following rewrite rule in wordpress .htaccess using add_rewrite_rule() function. RewriteRule ^admin-panel/(.*) wp-admin/$1?%{QUERY_STRING} [L] how can i proceed? Thanks advance.