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
13 views

Is it possible to change redirect template through a shortcode?

I have added a redirect for my plugin in init: add_rewrite_rule( 'city/([a-zA-Z]+)/?$', 'wp-content/plugins/csv-to-html/templates/csvtohtmlpage_core.php?city=$1' ); When I go to <site>/city/...
0
votes
1answer
10 views

Relationship between set rewrite flag in register_post_type and add_rewrite_rule

In register_post_type, I can register a custom post type and set parameters, including rewrite. Based on https://developer.wordpress.org/reference/functions/register_post_type/#rewrite, if it set to ...
0
votes
1answer
22 views

Order of rewrite rules when calling add_rewrite_rule

I am checking the document for add_rewrite_rule at https://developer.wordpress.org/reference/functions/add_rewrite_rule/, based on its description, it said "Any value in the $after parameter that ...
0
votes
0answers
20 views

add_rewrite_rule() issue with parent/child/child page

I have a parent/child and another parent/child/child pages. I have 2 separate page templates for both pages and the following add_rewrite_rule() code in place: add_rewrite_rule( '^user/dashboard/([^/]*...
0
votes
0answers
13 views

Custom Post Type add_rewrite_rule

I have a small detail in a wordpress site, I would like to modify the url of the sinlge post of a specific type of content: post-type = book Current permalink = site.com/book/title-book I want to ...
1
vote
1answer
59 views

Can I write 'RewriteCond' using 'functions.php'?

I want to add 'rewrite condition' in .htcaccess but unfortunately I don't have access of that. Can I write conditions in functions.php ? If yes, how to achieve that ? I want to add these lines: ...
2
votes
0answers
15 views

Newbie question: no index.php? in my plain wordpress permalink

I am trying to learn about the Rewrite API and I see people write their plain permalink as "index.php?page_id=", but my local Wordpress site shows "?page_id=" instead. Is there any ...
0
votes
0answers
20 views

Wordpress rewrite with custom parameter doesn't work

I'm currently developing a plugin which takes a parameter from URL (example: example.com/product_id/1234 is converted to example.com) and passes it in WP_Query (supposedly this should be used instead ...
1
vote
1answer
31 views

add_rewrite_rule - Additional subpages for author pages

I want to add additonal sub pages to the author pages in WordPress. I have the following URL: http://mylocalsite.site/author/USER_NAME/ But I also want to add URL's like this: http://mylocalsite.site/...
1
vote
0answers
29 views

How to change custom post type permalink structure

I have 2 Custom Post Type : article and multipager_article Now I want to customize permalink structure for these 2 custom post type only I want Structure like this : site_url/term_slug/post_id I ...
0
votes
0answers
40 views

Adding custom query var to a single post without redirecting to its root slug

I have created a post to posts relationship using ACF. On the single page of one of my CPTs I would like to add a prettified ID to the end of the slug to load different values on the page (/my-archive/...
0
votes
0answers
20 views

Force custom taxonomy query to redirect to a pretty link?

We have custom taxonomy that is 'news-categories' with a term such as 'news' and 'press'. I set up a rewrite rule using wp_rewrite so that visiting 'domain.com/news' will display an archives page for ...
0
votes
1answer
36 views

How to query 2 custom post types that need to share a slug?

I'm trying to make 2 custom post types (authors and works) share the same slug. The authors CPT uses an archive page which functions properly, but works CPT does not need one. CPT 1: https://domain....
0
votes
0answers
20 views

404 for custom static link on IIS with URL Rewrite Module

I need to use IIS to develop the new WordPress site. After reading a lot of articles, I installed the URL Rewrite Module on IIS (https://www.iis.net/downloads/microsoft/url-rewrite). My site structure ...
1
vote
0answers
14 views

Custom permalinks with hierarchical taxonomy - getting PHP warning

I have a site where a CPT needs to have permalink structure with custom taxonomies (parent and child). Following this solution https://wordpress.stackexchange.com/a/75172/210080 I got custom ...
0
votes
0answers
17 views

How to create a custom url for a specific page?

I want to create a custom url based on post slug. Suppose i have some posts i.e. https://example.com/my-post-slug-1 https://example.com/my-post-slug-2 In my post i have a custom meta field url which ...
0
votes
0answers
13 views

Generate custom output on URL with directory

I'm trying to create a custom URL where I will output some string. The problem is that I want this URL to include a /.well-known/ directory and when I do this, 403 forbidden error occures. So my ...
0
votes
1answer
43 views

Create a permalink to a pdf?

I have a website where I want the permalink to my resume to be www.example.com/resume, so that whenever I send someone that link, it goes to the most recent version of my resume. But I don't want my ...
0
votes
0answers
18 views

Create different permalinks for same post

I am working on a website where we have blogposts. These blogposts have 2 custom taxonomies: subject and region. The permalink of a blogpost looks like this: /subject/blogpost-title my normal ...
0
votes
1answer
48 views

Combine multiple CPT names to create valid permalinks

I have three different Custom Post Types: Company Employee Project They are connected with ACF relationship fields so as the Company can have multiple Employees and each Employee can have a project ...
0
votes
0answers
19 views

Custom URL rewrite rules for a web app

I'm working on a wordpress install that functions more like a web application than a traditional website, and I'm trying to get my head around the add_rewrite_rule system. Currently I have three ...
0
votes
0answers
32 views

Rewrite Rules not redirecting with Custom Post Types

Scenario There are two CPT: kd_artwork & kd_gallery. kd_artwork has an ACF field which specifies which kd_gallery it belongs to. This works so far in that I can access: http://localhost/kd_artwork/...
0
votes
1answer
38 views

remove SLASH on single_post but KEEP on categories and parent pages

My current permalink structure is  /%category%/%postname%/  which produce urls as: (category_base removed using "FV Top Level Categories" Plugin) category: example.com/class-10/science/ ◀▬...
0
votes
1answer
33 views

Page get parameter doesn't work with is_single() function

If exist the page parameter in the blog post, I have to redirect to the 404 page instead of current post URL. I tried to check the current page type (is singular) and try to get page parameter in the ...
0
votes
1answer
20 views

Add variables from rewrite rules to query var

I'm trying to store query variables to a localized variable in the frontend of my plugin. rpSearch shows up like it should but page and share_id are "0" and "" respectively when I ...
0
votes
0answers
22 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&...
0
votes
1answer
76 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&...
0
votes
3answers
219 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
173 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
43 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
30 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
47 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
45 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
17 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
15 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
37 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
28 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
137 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
18 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
178 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
22 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
28 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
25 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
10 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
17 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
15 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
32 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
15 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 ...

1
2 3 4 5
23