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
0answers
17 views

How to apply multiple rewrite_rule to a single custom post type url?

I have created a custom post type named bollywood, and a rewrite rule in order to map a URL such as example.com/bollywood/old-movies-of-hero1-with-hero2 to the query index.php?post_type=bollywood&...
1
vote
1answer
63 views

Bilingual WP site: How to achieve different URL sturcture rule based on its language?

A wordpress website with bilingual setup, with three languages: English ("primary language") : "en" Traditional Chinese : "zh-hant" Simplified Chinese : "zh-hans&...
1
vote
3answers
38 views

How to add custom rewrite rules and point to specific templates

How can I add a custom rewrite rule so I can catch paths like these: /products/imports/filters /products/imports/elements /products/imports/parts And point them to a template file, for examples: ...
3
votes
1answer
99 views

Custom taxonomies, with custom rewrites/slug, AND loading a taxonomy archive template from a plugin

I think maybe my understanding about rewrites and templates for custom taxonomies and CPTs is wrong and maybe someone here could help me solve my problem and educate me. So I have a post type, "...
0
votes
0answers
40 views

Rewriting subfolders to specific parent folder in Wordpress

I have created one page with name /parent/ and assigned new template template-parent.php that has some 3rd party software showing via JavaScript. I need to rewrite all subfolders to this parent so ...
1
vote
0answers
27 views

Share same Slug for a Custom Post Type and 2 Taxonomies

I'm trying to achieve an URL structure that implies sharing the same slug ("videos") for a Custom Post Type (video), and two Taxonomies (video_category, video_tag), in order to have: Page: /...
0
votes
0answers
42 views

Rewrite Search URL Permalink For CPT Custom Taxonomies

My site uses a CPT with custom taxonomies and shows this URL for searches : https://example.com/?s=&post_type=listing&location=bridgeport&sale_type=for-sale&property_type=office But ...
1
vote
0answers
41 views

Rewrite custom post type URL parameters

I would like to change the following parameterized URL: www.example.com/category/?keywords=&location=new-york&type=Wedding in this way: (invert city > category) www.example.com/category/...
1
vote
0answers
14 views

How to change category and year archive permalinks/rewrite rules?

first of ll I'd like to find a way to substitute 'category' with 'events' in permalinks. Currently I've got this: http://example.com/category/post-name/ And I would like it to be: http://example.com/...
0
votes
0answers
10 views

Rewrite rules showing blog pagination 404 error

I added below script in my website to setup custom language slug like th, se etc. After adding this below script my pages are working like. www.mywebsite.com/ www.mywebsite.com/se/ www.mywebsite.com/...
0
votes
0answers
11 views

File cannot get POST ID with rewrite rule enabled

I have this file that has always gotten the wordpress post_id correctly: <?php require('C:\xampp/htdocs/wp-blog-header.php'); require('C:\xampp/htdocs/wp-load.php'); ?> WP Post ID: <?php ...
1
vote
0answers
30 views

How do I get WordPress URL rewrites into Sitemap?

Consider the two following custom post types: Museums Bakeries With one shared taxonomy: Region I'm using rewrite rules to improve the URL structure, so I can serve pages to visitors such as: ...
0
votes
0answers
21 views

Doing add_rewrite_rule only for specific post type

so I have these two rules for projects CPT. function addMyRules(){ // variables add_rewrite_tag('%eventid%','([^&]+)'); add_rewrite_tag('%version%','([^&]+)'); // release-...
0
votes
0answers
23 views

Disable Wordpress URL by ID number

I have a post URL like this: https://domain.com/cpt/post-item/ which has a post_id: 1234. But if I change the URL to this: https://domain.com/cpt/1234/ or this https://domain.com/cpt/?p=1234 or this ...
2
votes
1answer
50 views

How to exclude a directory from WordPress permalinks in a Multisite environment?

The scenario is as follows: A multisite install with three sites: site1.com (admin) site2.com site3.com Q: How to exclude a folder located in the root directory, which should also be associated with ...
1
vote
0answers
17 views

Front custom edit post page for each post

I have made a custom post type named ticket and I want to make an edit page for every single ticket like StackOverflow if the question is like this: wordpress.stackexchange.com/questions/109592/how-...
1
vote
1answer
106 views

.htaccess rules for blocking bots with an extra condition

I have a WP multisite installed. I am integrated with Ezoic and Cloudflare. I had implemented firewall rules. However, I have an issue blocking bots that have X-Middleton in the User-Agent, because my ...
0
votes
1answer
19 views

Custom Post Type - Rewite Archive page

I'm trying to figure out the following : I have a CPT called "Podcast" which has a slug as /podcasts/ I have a Page called "Podcasts" which has a slug as /podcasts/ I want my ...
1
vote
0answers
26 views

add_rewrite_rule is redirecting instead of rewriting url

I have a page that is accessible at /products/. I want to be able to access it at /products/canada/ontario/toronto/ (and not redirect to /products) The place names after /products/ should be query ...
0
votes
1answer
17 views

Best way to trigger rewrite rules

I typically call the rewrite rules with this action add_action('init', 'add_my_rewrite_rules') But what I do not like about it is that the rewrite rules are written every time an init action is ...
0
votes
0answers
9 views

Exclude “Blog” Page From .HTML Extension Addition in wp_rewrite

I currently have all the permalinks for pages/posts on my site on my site rewritten to add .HTML to the structure. However, in an effort to avoid 301 redirects I would like to exclude the blog page ...
0
votes
0answers
14 views

WordPress rewrite rule and programmatically flush rules drop my rule

I have following rule, add_action( 'init', function(): void { add_rewrite_rule( '([^/]+)/search/(.+)/?$', 'index.php?post_type=$matches[1]&s=$matches[2]', 'top' ); } ); It give me searchable ...
0
votes
0answers
14 views

custom url for each menu

I have designed a plugin that has a page for user account with custom templates and graphics. Inside this page there are menus that each have a separate content. just like a WooCommerce my-account ...
0
votes
1answer
25 views

Add rewrite rule for archive search

I want to searchable archives like following: Default Search: /search/{keyword} -> search.php -> get_template_part('archive-default-search'); Default Custom Archive: /support -> archive-...
1
vote
0answers
14 views

Changed pagination URLS to use p= instead of paged=

I am trying to rewrite my pagination URLs to use p instead of paged so they go from... example.com/myposts?paged=2 to example.com/myposts?p=2 How is the best way to do this? Do I need to use the ...
0
votes
0answers
13 views

Rewrite Custom Post Type URL without breaking RSS Feed URL

I am rewriting the URLs for a custom post type as follows: In my register_post_type code I have: 'rewrite' => array( 'slug' => 'magazine/%magazine_categories%', 'feeds' => false, '...
1
vote
1answer
41 views

404 error- issues with pages after adding custom rules for posts

I am trying to create a custom translation for my website. Quick Story: I am facing "404 error-Page Not Found' issues with pages after adding custom rules in functions.php $newrules['^th/(.*)$'] =...
0
votes
1answer
23 views

How can I use get_post_meta with add_rewrite_rule to build custom permalinks?

I'm trying to change the url structure of my custom post type posts, but It's not working correctly right now. What I'm trying to do is change the urls of my custom post type (Test) posts via ...
1
vote
0answers
35 views

rewrite URL based on selected taxonomy for post page

I have a taxonomy called "group", and their values like "red", "blue", "green" (these are generating dynamic" no any fixed group value. during post ...
0
votes
1answer
28 views

How to override url params with rewrite rules vars?

Setup a rule: add_action( 'init', function() { add_rewrite_rule( '^myparamname/?$', 'index.php?myparamname=hello', 'top' ); } ); Whitelist the query param: add_filter( 'query_vars', function( $...
0
votes
1answer
69 views

What's the Simplest Way to Override/Rewrite the %category% Permalink Structure Tag?

See: https://wordpress.org/support/article/using-permalinks/ By default, when someone sets their permalink structure to: /%category%/%postname%/ Post URLs appear like so: https://example.com/**abc**/...
0
votes
0answers
20 views

How to get pagination to work despite naming conflict?

I have been stomped for the past two days trying to understand wordpress' permalink structure. Right now, I have a a custom post type called venue and I have a custom taxonomy venue-type (e.x. hotels, ...
1
vote
0answers
41 views

Adding Post id to the end of slug in a Custom Post Type

I have created a Custom Post Type (jobs) - Functions fine. But due to the possibility of duplicate page titles by admin, I need the permalink/slug to include the Post_ID to the end of the Post title, ...
0
votes
0answers
19 views

How to properly set the rewrite rules for this case?

I'm having an issue wih the rewrite rules. I can't figure out how to properly build it to get what i want. I got a taxonomy with a slug called "acceso-mayorista", which mean a place where ...
0
votes
0answers
43 views

Assigning CPT as post child to another CPT results in 404 for single-childpost.php

I have two custom post types: movie and screening. screening is a child of movie, and a movie can have several screenings/children. (screening is registered as hierarchical, both are publicly ...
1
vote
0answers
18 views

Displaying Post with Custom URL with RewriteRule or add_rewrite_rule

I'm having what I believe is a common issue: I want to display a post with a slug with a custom URL, in my case, this is the format /resources/{state}/{city}/{location}/ which would match a post slug ...
0
votes
0answers
22 views

Why am I getting 404 after using category_link and post_link filters?

I want to customize the posts category and single permalinks. I'm doing something like this: add_filter('post_link', 'set_post_links' , 10, 2); function set_post_links($permalink, $post){ if(...
0
votes
0answers
22 views

CPT - Nice url with add_rewrite_rule

I read lot of topick, but it don't work. And I really don't know what i do wrong ... I put this code the the function.php of my child theme : function capitaine_rewrite_url() { ...
0
votes
0answers
17 views

Multiple Taxonomy Items for Separate URLs

Can anybody just let me know if this is possible for the start? I have Custom Post Type "Recipes" and a Custom Taxonomy "Type", which consist of multiple items: breakfast, snack, ...
0
votes
0answers
11 views

How to fix URL segment conflict from page and post type URL?

I have two different pages like, 1 :- http://example.com/notebook/note-name-x/ // Real Page 2 :- http://example.com/resource/note-description-x/ // Created by post type Then i have changed second ...
0
votes
0answers
13 views

rewrite .htaccess on wordpress to subdirectory

I have wordpress installation on root site folder. Then I will need to pointing some url to set to subfolder. wp-admin wp-content wp-includes subfolder ....etc When user access some url like below: /...
0
votes
0answers
9 views

Post slug cannot be edited after add add_rewrite_rule

Because I wanted to add a blog reference to the slug of each post, I add a add_rewrite_rule. But now the slug can not be edited on the dashboard. How can I make the slug editable? my dashbord: my ...
1
vote
1answer
66 views

How much control do we have over CPT rewrite slugs? Can I create a “root” page for my CPT with out the page path, and then have paths for other pages?

Say I have a CPT called I dunno, "Library" which is just a set of "pages" ("has_archive" => false) and the rewrite slug is "library". I also intend to have ...
0
votes
0answers
4 views

WordPress rewrite rules get erased periodically

We are facing a very strange issue with our WP instance. At random intervals, the WP permalink structure gets reset to the default settings, and then we get 404s on all custom pages like events, ...
0
votes
1answer
18 views

Fire a code when permalinks updated

I would like to execute some php code when permalinks updated, I think some plugins I'm using them updates permalinks programmatically sometime and this breaks my some slug rewrite settings, at this ...
0
votes
0answers
49 views

Rewrite WordPress Url from root to subfolder without moving files

I have a WordPress installation in the root folder "example.com/". I want the url to be "example.com/blog". (Rewrite from root to folder "/blog/") Is it possible to do ...
0
votes
0answers
12 views

How avoid error 404 after add post id to slug for custom post type? (post_type/%post_id%-%slug%/)?

I want to have permalinks which will be look like: example.com/mypost/%post-id%-%slug%/ And the following code do it. But when I try to go to url of the post... I get error 404. I have this code: To ...
0
votes
0answers
12 views

Configuring separate permalinks for posts and archives

I'm working on a site where posts are organised by category/year/month/posts. /%category%/%year%/%monthnum%/%postname%/ I've had a request to provide the site category/year/month archives (/%category%/...
0
votes
0answers
18 views

get_categories() retrive post_tag instead category

I want to rewrite my category to a specific URL. but I get post_tag instead of category when I use get_categories(). Here my code add_filter( 'category_rewrite_rules', '...
0
votes
0answers
21 views

.htaccess to redirect to a wp page

My custom .htaccess commands are above the WP ones. This is working: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^$ wp-content/ahoj.txt [N] </IfModule> It shows the contents of ...

1
2 3 4 5
23