Tagged Questions

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

1
vote
1answer
27 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
18 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
19 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
13 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
44 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
16 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
28 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
14 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
13 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
54 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
73 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
37 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
24 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
32 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
255 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
42 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
42 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
23 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
34 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
22 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
59 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
43 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
20 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
81 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
32 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
122 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
32 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
63 views

WordPress permalinks with Windows Server IIS6 - without ISAPI access

I'm having trouble to export the website to my client hosting . . I get an index.php in the url all the time, I've research about it, change the permalink custom structure to: /%postname%/ and add ...
0
votes
0answers
14 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
42 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
31 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
24 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
32 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
63 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
43 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
34 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.
0
votes
0answers
89 views

Changing attachment page Permalink

How can i change the attachment page permalinks to http://domain.com/photos/%attachment_id%/%postname%/%attachmentname% currently my permalinks set to Custom Structure ...
0
votes
1answer
99 views

Rewrite Rule for Post “Subpage”, with pagination

I would like to know if is possible to add a "subpage" to a post and in this "subpage" have paginated content, for example: I Have a Post Lorem Ipsum This post has Videos, Photos and Audios as ...
0
votes
0answers
22 views

add_rewrite_rule is not fired

I need to rewrite some urls: I have a page (id = 61), with slug anunciantes on wich I use a custom template to generate a wp_query to list a custom post_type. I need to be able to filter by two ...
0
votes
0answers
19 views

Register frontend page without access in backend

I'm looking to register a page that can be accessed from the frontend, while not actually having it show up as a "page" in the admin. I had thought about creating the page programatically and then ...
0
votes
0answers
19 views

images gallery attached to a post as a subfolder of the same post

I would like to know how can I set the Lazyest gallery or other gallery plugin in order to add many pics to a post and the URL's pics to appear as a subfolder of URLs' post? For better understand ...
0
votes
0answers
55 views

How to programatically create a simple HTML page using the permalink of a Wordpress post?

I want a create a simple HTML page (not Wordpress Page) programmatically by using the permalink structure of another already existing post. E.g. Already existing post is ...
1
vote
1answer
72 views

How do I add a add_rewrite_rule without it redirecting?

I have a custom post type called "locations". I have a location called "starbucks". I can view this by going to "/location/starbucks". I would like to add "coffee-shop" to the URL, so the path ...
0
votes
1answer
62 views

Pretty Permalink for Search Queries Not Working

As the title suggests I am trying to create pretty permalinks for search queries, but unfortunately I cant get them to work. I am trying to achieve the folllowing: ...
0
votes
0answers
38 views

URL Rewrite for CPT single posts

I'm struggling with Wordpress' rewrite function I have the following URL structure http://example.com/album/test-7/ 'album' is the slug for the CPT single page 'test-7' is the slug for the CPT ...
0
votes
1answer
45 views

How to add a Rewrite Rule / Category Structure

I'm currently trying to use add_rewrite_rule() to create a rewrite (duh!), for a custom taxonomy page. I've added the rewrite tag "sort" with the following code: ...
0
votes
0answers
40 views

Why is my rewrite rule refreshing the page and removing my variables?

For some reason, the catch-all page rewrite rule is capturing this rewrite, rather than my own rewrite rule. My rewrite rule is listed at the top when doing a var_dump of the rules, as well as when ...
0
votes
2answers
90 views

add_rewrite_rule not registering on Multisite

I have a multisite install of WordPress. I have installed the plugin Monkeyman Rewrite Analyzer so I can see all the rules I have registered. The code below is how I am registering the rule: ...
0
votes
1answer
152 views

Call to a member function add_rule() on a non-object

I want the page mysite.com/product to be accessed with the URL mysite.com/product/productname instead of mysite.com/product?name=productname I am trying to achieve this with the code in the ...
0
votes
0answers
63 views

add_rewrite_rule regex issue

I am trying to add the following function into my functions.php through the WordPress editor but every time I try it says error 403 Forbidden - Access to this resource on the server is denied! ...