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
8 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
9 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
25 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
20 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
22 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
37 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
49 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
17 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
15 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
13 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
13 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
18 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
11 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
40 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
21 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
27 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
36 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
42 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
17 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
19 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
21 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
8 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
11 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
16 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 ...
0
votes
0answers
29 views

When I modify the product's permalink, the pages stop working

I'm trying to modify the Woocommerce slugs with the object $wp_rewrite. When I modify it, everything works as I put it, but the rest as the pages stop working. Here the code: public function rewrite():...
0
votes
1answer
15 views

How to change Custom Permalink for Taxonomy? (remove the slashes from term-slug)

I have my code to register my custom taxonomies. function themename_custom_taxonomies() { // Coaching Method $coach_method = array( 'name' => _x( 'Nieruchomość', 'taxonomy general ...
0
votes
0answers
10 views

Best Place to 404 a Non-Matching Custom Query Var

I've created a 'tabbed' layout on custom taxonomy archives on my website and successfully rewritten my permalinks so that visitors to mywebsite.com/player/player_name/tab_name see some conditional ...
1
vote
1answer
180 views

remove query arg from url after set query

i make migration plugin from specific script to wordpress, but i have a problem on redirect old urls to new one old urls is like book.php?view=12a34b56 and i want redirect it to book/12a34b56 i try to ...
0
votes
1answer
12 views

Rewrite only if no other matching page is found

I'm rebuilding a site in which I am required to change the URL structure for archive pages to something that WordPress doesn't handle by default. I have a custom post type named product, which has a ...
0
votes
0answers
32 views

ErrorDocument 410 gives me back a 302 header

I've deleted several pages and tags from my site, and bases on my SEO recommendations I've redirected them to 410. I've done that in my .htaccess file this way: RewriteRule ^tag/lorem/?$ - [G] ...
0
votes
0answers
21 views

How can I make rewrite rules for a custom post type?

I'm trying to create rewrite rule which will work this way: when user enters URL site.com/projects/projectname/cityname it should work as site.com/?projects=projectname&city=cityname, where: ...
0
votes
1answer
23 views

Getting back a permalink from custom url

okay i have made my own rewrite rule, with the add_rewrite_rule function in wordpress to get a custom url, for an plugin page. add_action( 'init', function() { add_rewrite_rule( 'login/?$', 'index....
0
votes
0answers
69 views

URL rewrite for mu-plugin assets

I have a semi-bespoke scenario, but one that works best for out environment sharing the code workload and accessibility (and version control). We have a multisite that all abide by the same core ...

1
2 3 4 5
23