Questions tagged [rewrite-rules]

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 abstraction between the files used to generate a web page and the URL that is presented to the outside world.

Filter by
Sorted by
Tagged with
0
votes
1answer
21 views

$wp_rewrite->rules is always NULL

I am trying to learn how WordPress uses the rewrite API to rewrite pretty to ugly URLs . I have some ideas as to how rewrites work in .htaccess file but not how WP handles it . I am reading through ...
0
votes
0answers
7 views

How can I add a vanity URL for admin-ajax.php Calls?

Background I'm using the admin-ajax tool in WordPress to build a file generator. I have everything working, except that the current URL is ugly. I'd like to add a vanity URL that looks cleaner. My ...
0
votes
1answer
36 views

Using a template file for a specific custom URL

I was trying to use a custom URL to load a page template for single-events.php without rewriting the default URL format. I am using filter template_include to load the template like this: add_filter('...
0
votes
1answer
9 views

Remove part from dynamic url and redirect

How do can I redirect the following URL to the next URL? It essentially should remove the ID part (this is a post tag URL). http://wpsoup.test/tag/88/koffie/ -> http://wpsoup.test/tag/koffie/. I've ...
0
votes
0answers
26 views

Rewriting request to another site

I have a multisite WP instance set up to use subdirectories. I have a few pages that should have URLs on each site. The content will be (almost) the same, so I wanted to just make the pages once and ...
0
votes
0answers
16 views

Worpdress Elementor. How to read query variable from rewrote url in?

I need to create a Elementor page which should have the following URL structure: /order/(.*?)-([0-9]+)?$ At this page I should display a Elementor widget which will display information about order ...
0
votes
0answers
16 views

Rewrite rule for wp

I have a URL which i want to change the query string to slug. site.com/shop/?test=new I want to get get the output as ? site.com/new But i don't want to get it redirect to any other page rather ...
0
votes
0answers
26 views

Wordpress Own Rewrite Rules

i am trying to rewrite a URL with the following code in functions.php add_action('init', function() { add_rewrite_rule('/agbz\/(\w*)\/\?page=(\w*)&memberID=([a-z]{1}\d*)&land=(\w*)&...
0
votes
0answers
16 views

Rewrite dynamic URLs as pretty URLs in Wordpress functions.php (add_rewrite_rule) - what's wrong with my code?

I'm using an events calendar plugin to list events on my WordPress site. It uses a custom post type to give each event its own page. There are one-off events and recurring events (eg an event that ...
0
votes
0answers
21 views

The same rewrite slug for multiple taxonomies

I'm using the plugin custom post type ui and I have a custom post type with multiple taxonomies and I'm trying to get my URLs to work. Custom post type → works Taxonomy1 → works_cat Taxonomy2 → ...
0
votes
1answer
21 views

How to get relative page for every post: /post-1/contact. /post-2/contact

Let's say I have a post type called jobs, and a page called contact with a form in it. Now I want the contact page to show on every job url ending with /contact. So job-1/contact, job2/contact etc. I ...
1
vote
0answers
16 views

Rewrite rules automatically for pages using specific template

I'm using rewrite rules to add an optional parameter to a page. This page uses a specific page template which handles the implementation of an external data source. add_rewrite_rule('^page/([0-9]+)/?'...
1
vote
0answers
16 views

How to use add_rewrite_rule in subdomain

I need to understand the concept of add_rewrite_rule() in wordpress in my case I have a subdomain based website by wild card I created a custom page called X.php This custom page function is to get ...
2
votes
1answer
31 views

url keeps redirecting to a page

I have theme options pages www.website.com/wp-admin/themes.php?page=avada_options but problem is when ever i go that page it redirect to www.website.com/store-manager/ I checked the rewrite, even ...
0
votes
0answers
21 views

Rewrite rules for custom taxonomies

I got car custom post type. And got custom taxonomies (model, year, color) for car post_type. Car archive link looks like this: https://example.com/car/ And i am filtering this archive page with $...
1
vote
0answers
18 views

Redirect based on a query string

I am working on project where the previous web developer has left the company. There is redirect happening based on the query string and I can't figure out where. The example URL is https://www....
1
vote
0answers
18 views

Change pagination url format

I have a URL like this: example.com/blog/page/5 I want to change it to: example.com/blog/page-5 I tried using a RewriteRule like this: RewriteRule ^blog/page-([0-9]+) /blog/page/$1 but this ...
0
votes
0answers
26 views

Is it possible to use multiple post_name, post_title and post_content?

I'm actually writing a localization plugin. Here I have developed something like "localhost/post-title", "localhost/de/post-title", "localhost/ru/post-title". From this point on, is it possible to ...
0
votes
0answers
26 views

CPTs relationship

I have two CPT - project and publication. Is there a way to "connect" those CPSs to the permalink looks like: foo.com/project/lorem/publication/ -> archive-publication.php foo.com/project/lorem/...
1
vote
0answers
35 views

How to remove specific category from URL in Wordpress

My custom structure permalink is set as shown below and category base is set to . /%category%/%postname%/ My current URL structure is this: http://example.com/aaa/slug http://example.com/bbb/slug ...
0
votes
0answers
35 views

True or F False Setting of 'with_front' Parameter of Rewrite Is returning Exact Same result

Setting the 'with_front' to true or false in my Custom Taxonomy is landing to the exact same urls as http://localhost:8080/wp/commercial-services/action/ http://localhost:8080/wp/commercial-services/...
0
votes
1answer
25 views

add_feed rewrite overwriting standard permalinks

By doing a simple: add_feed( 'schedule', 'my_schedule_feed' ); I have created a feed at /feed/schedule/... easy. But when I go to /schedule/ (which is a page) it is now showing the feed! Looking ...
0
votes
0answers
21 views

Why is this rewrite rule not working (for a custom route)?

I am trying to setup a paypal return url of the form somesite.com/paypal-return In my child theme root I have file called paypal-return.php In my child theme functions.php I have /* * Set up a ...
1
vote
1answer
37 views

Special domain for a page

I have a wp instalation on example.com and want to have secondary.com to show contents of example.com/b (b is a page) but keep secondary.com in the url (not secondary.com/b) I tried this approach: ...
0
votes
0answers
11 views

Build optional prefix for both post and pages, based on meta

I have posts and pages that have a metabox "new" which saves the meta new in the database for the post. What I am trying to achieve is to have an optional prefix /new/%slug% which shows the post if it ...
2
votes
1answer
173 views

Rewrite url for existing page without flush_rewrite_rules

I have created pages with slug test123 and test234 in wordpress, I want to create a plugin that doing the following when user request test123, and the content in test234 will be served instead. I ...
0
votes
0answers
25 views

Custom post type + category archive page

I have default post type "post" and created custom post type "restaurants". I have categories (not taxonomy): cat1 and cat2. I want to work with same categories on both post types and I don't want to ...
0
votes
0answers
21 views

Create category with special permalink

My usual permalinks are /%year%/title but for posts that in the category timeless, I want to remove the year. I have the following code, but the issue seems to be add_rewrite_rule is having no ...
0
votes
1answer
18 views

Multiple Custom Taxonomy Rewrite

I have registered two custom taxonomies of 'location' and 'type' registered before my post type of 'chalet' and have the rewrite rules set to 'slug' => 'chalets/%location%' 'slug' => 'chalets/%...
0
votes
0answers
12 views

Wordpress rewrite rule from archive.php to archive-posttype.php

question Hello. Tell me how to make rewrite_rule. 1) there are terms of taxonomy that are displayed in the menu. eg post_type - publications taxonomy - publications_type term - novyny link of this ...
0
votes
0answers
17 views

How to update rewrite rules after making “post” post type hierarchical?

I made the default "posts" post type hierarchical and added a filter to "post_link" that calls get_page_link on the $post->ID if a post parent is present. Then the parent-child-relationship is ...
0
votes
0answers
23 views

Different Post URL Base for Specific Categories

By default WordPress allows you to edit the permalink structure: Ideally wanting to have most posts as a simple URL such as site/post-name. However a few categories such as events, news, and albums I'...
1
vote
0answers
15 views

Category archive rewrite rule to include category/subcategory?

I'd like to have my category archive (category.php) accessible using via a url structure like: mysite.com/mycategory/mysubcategory For example, I've got "health" as a category and "smoking" as its ...
0
votes
0answers
55 views

WordPress Multisite ABSPATH and get_home_path() to check for htaccess or web.config file

Looking to update my WP Login Flow open source plugin to prevent using rewrite URLs in things like Lost Password, Login, Register, if the rewrite file does not exist on the server -- but need some ...
1
vote
1answer
187 views

Rewrite rule to load images from production does nothing

I'm trying to adapt the rewrite rule given in Develop Locally, Use Images from Production to do the very same thing on my local dev site (which runs on XAMPP). This is how the development site's ....
0
votes
0answers
26 views

Multiple Pretty Permalink Rewrites for Custom Taxonomies

I have a custom post type and two custom taxonomies. I'm already successfully rewriting the first taxonomy titled 'type' to website.com/post_type/tax_term. I am doing so by adding the following ...
0
votes
2answers
90 views

How to add custom taxonomy in custom post type permalink?

I have a custom taxonomy called campaign and a custom post type called asset. For assets, I want to have the following permalink structure: mysite.com/<campaign_name>/<asset_name>. I have ...
1
vote
0answers
39 views

Changes in permalink structure in WordPress and how to apply to in-site links

I have some work for wordPress internationalization. Actually, I got good results. Part of my code: add_filter( 'query_vars', 'queryi18n' ); function queryi18n( $query_vars ){ $query_vars[] = '...
1
vote
0answers
58 views

Wordpress Persistent connection rule does not work for “posts”

add_action( 'init', 'rule' ); function rule() { add_rewrite_rule( '^(en|fr|de|ru)/(.?.+?)/?$', 'index.php?lang=$matches[1]&pagename=$matches[2]', 'top'...
0
votes
1answer
68 views

Adding URL prefix for foreign language support

I've done some research to use it for my own complicated system (Using Plugin or Functions.php). In fact, what I want to do is add a prefix at the very beginning of the URL structure of WordPress and ...
0
votes
0answers
16 views

Need help to write custom rewrite rules correctly

In my site I have a page with permalink http://dev.mysite.test/option/ and I pass it some values with query string, e.g.: http://dev.mysite.test/option/?value=100, how can I write a correct custom ...
0
votes
0answers
27 views

WooCommerce multiple shop bases and rewrite rules

I have a simple installation of WooCommerce that I need to display under two different URLs like so https://www.something.com/shop/category/product https://www.something.com/knowledge/category/...
0
votes
1answer
44 views

Custom rewrite to fetch feed data

I am trying to fetch and display data from a feed when the user goes to a specific url like /items/32 where the 32 is the actual id of the feed item that should be fetched and displayed. Notice that I ...
0
votes
0answers
42 views

get_author_posts_url() doesn't return the author URL, because of wrong author_structure

I have the following code to modify the author base on WP: add_action('init', 'modify_author_slug'); function modify_author_slug() { global $wp_rewrite; $wp_rewrite->author_base = 'user'; ...
0
votes
1answer
39 views

How can I add rewrite rules to a class-based plugin?

I'm working on a custom plugin that requires a few rewrite rules. I've followed the documentation but the rules aren't executing. I've tried some variations but I keep getting errors. This is an ...
0
votes
0answers
28 views

How to redirect to a login virtual page?

I'm writing my first WordPress theme from scratch. I need to redirect not logged in users to a virtual login page, when I do wp_safe_redirect( get_site_url() . '/login' ) I would show a virtual page ...
0
votes
0answers
33 views

How to create multiple Rewrite-Rule for various site in single htaccess?

I am using a single database for two different sites. One is sitejury.com and the other is cdn1.sitejury.com. I'm trying to serve my files using the subdomain. Previously I used simple https Rewrite ...
0
votes
1answer
108 views

WordPress add_query_arg from ajax and make url friendly

In WordPress I have set a query arg in ajax like this add_action( 'wp_ajax_get_prepare_link', 'prepare_link'); add_action( 'wp_ajax_nopriv_get_prepare_link', 'prepare_link'); function prepare_link()...
0
votes
0answers
22 views

Custom rewrite rule help

I am trying to solve a rewriting issue. Basically After quite a bit of research, I came up with this custom rewrite rules: $category = 'category'; $page_slug = 'florida'; $...
0
votes
1answer
19 views

Rewrite rule can't get the ID from rewrited

I use this simple rule : add_rewrite_rule( '^product/([0-9]+)-([^/]+)?$', 'index.php?pagename=product&id=$matches[1]&slug=$matches[2]', 'top' ); It works, it redirects to the ...