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
7 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
37 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
18 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
32 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
64 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
29 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
40 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
16 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
11 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
19 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
10 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
12 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
7 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
64 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
43 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
19 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
21 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
10 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
59 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
22 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
20 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
19 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
1answer
61 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 ...
0
votes
0answers
12 views

Why did my registered rewrite rules get deleted?

I'm using this code to register a rewrite rule: class Affiliate_Link_Utils_Redirector { public static function install() { add_filter('rewrite_rules_array', array(__CLASS__, '...
0
votes
1answer
18 views

Rewrite/Change custom taxonomy slug

I want this url: => mydomain.com/genre/chant to be rewritten as => mydomain.com/chambers/chant. I want the users to access mydomain.com/chambers/chant instead of mydomain.com/genre/chant. genre ...
1
vote
1answer
61 views

NGINX rewrite rules for sub subdomains

I was wondering if it's possible to set-up an NGINX rewrite rule for a WordPress Multisite that redirects anyone using the following: www.sub.domain.com to sub.domain.com. The issue we seem to be ...
1
vote
1answer
63 views

Can't get custom rewrite tag, query var, permastruct (permalink structure), and rewrite rule to work properly together

Problem specification I'm implementing a website that is meant to host podcast shownotes and transcripts, and so I want custom permalinks and shortlinks for the webpages: Permalinks of the form /...
4
votes
2answers
60 views

How to change default page slug?

I have a CPT called jobs and a page named Job Apply. I am trying to achieve something like below url: http://example.com/job-slug/apply Where, job-slug can be any job. i.e Programmer, Developer etc.. ...
0
votes
0answers
35 views

Custom taxonomy shared across two custom post types - url rewrites

I'm using CPT-UI to create my custom post types and taxonomies. I have two post types - aulocations and uklocations these work and show up as: /au/locations/{location-names} /uk/locations/{location-...
0
votes
1answer
17 views

Name page template properly

I have custom taxonomy in place which builds URL that way: domain/course/course-name/lesson Course - is a custom post type. I am facing difficulty to reach the right template for lessons. I've tried &...
0
votes
1answer
166 views

How to add_rewrite_rule with two parameters to a single view page?

I'm having troubles understanding how add_rewrite_rule works in my case. I have a page which lists news from an external source. All items are linked with a "read more". Those links look ...
0
votes
0answers
15 views

Exclude image from cloudflare hotlink protection

I am want to exclude my newsletter images from Cloudflare's hotlink protection Based on Cloudflare's documentation, it is possible to do this with serving the image from a "hotlink-ok" ...
1
vote
0answers
62 views

Help with Rewrite Rule for Custom Post Type with Query String

I'm trying to get a custom rewrite working: I've got the following URL pattern for a custom post type of 'product': /au/product/product-name-one/?type=customtype1 /au/product/product-name-one/?type=...
0
votes
0answers
83 views

How do I get the correct URL?

Helo, WordPress Community! Help me, please. Created a custom post type with one taxonomy added as a category. Overwrite rules have also been created to display the complete structure of the CNC, for ...
1
vote
0answers
22 views

Rewrite URLs - Custom Post Type - Post Slug, Taxonamy Slug

Am using a third-party plugin for listing schools. Custom Post Type = school Custom Post Taxonomy 1 = school_type (eg. values = Primary, Intermediate) Custom Post Taxonomy 2 = school_location (eg. ...
2
votes
0answers
36 views

How to restore WP 5.4 behaviour where a numeric string could added to each page URL and parsed as “page” in WP 5.5?

In WP 5.4.x, I was able to add a number to the URL for any page, post, etc. (incl. custom post types), which WP interpreted as the 'page' for a multi-page post, even if that page or post didn't ...
1
vote
2answers
99 views

URL Rewriting for PHP script on an image URL

I built an image randomizer so that when I open a .php file in a URL that it displays the image with readfile($randomImage);. This works locally but when I upload it to the server it gets blocked by ...
0
votes
0answers
21 views

How Can I Create a Friendly Slug for a Dynamic Page?

I built a dynamic page template that pulls biography information from a MySQL table. The page works fine but the URL is ugly. Officer-Biography/?ID=1 I have a set of canonical slugs that I want to use ...
1
vote
2answers
115 views

Create Dynamic SEO Friendly URL for Virtual Page

I have a Wordpress site that is built to be a job listing board, and I'm looking to create SEO friendly URLs based on data that is stored in the database. The URL structure should include the state ...

1
2 3 4 5
23