Home » Custom Posts and Fields » Rewrite Rules
Benefits:
Here’s how it works:
Rewrite Rules
Benefits of Using Rewrite Rules in QuickBuildWP
Rewrite rules in QuickBuildWP allow you to customize your URL structure for better SEO, readability, and dynamic content filtering. Instead of relying on WordPress’s default query string format, you can create clean, user-friendly URLs.1. SEO-Friendly & Readable URLs
Before (Default WordPress URL)
https://www.example.com/?category=financial-institutions&tag=artisan
After (Custom QuickBuildWP URL)
https://www.example.com/financial-institutions/artisan
- More readable and user-friendly.
- Boosts SEO as URLs with keywords rank better in search engines.
- Easier to share and remember.
2. Flexible URL Structures
With QuickBuildWP, you can define your own custom patterns for dynamic content filtering.Example: Displaying Content Based on Category & Tag
If you want to filter posts based on category and tag, you can set up a rewrite rule like:https://www.example.com/financial-institutions/artisan
financial-institutions
→ Categoryartisan
→ Tag- WordPress will dynamically fetch and display posts that match both.
- Custom rules allow more flexible content filtering.
- You control how URLs structure your data.
- Easier for users to navigate content.
3. Avoids Query String URLs
By using rewrite rules, you avoid using ugly query strings (?category=financial-institutions&tag=artisan
), making URLs:
- More professional-looking.
- Easier to cache (better performance).
- Compatible with modern web standards.
How to Setup Rewrite Rules in QuickBuildWP
Overview
QuickBuildWP allows you to define custom rewrite rules to modify how URLs are structured and handled in your WordPress site. These rules are useful for creating SEO-friendly URLs and managing custom content structures dynamically.Step 1: Add a Rewrite Rule
To set up a custom rewrite rule, follow these steps:- Go to
Dashboard → Field Groups
. - Edit an existing field group or create a new one.
- Find the "Rewrite Rules" input field and enter your desired pattern.
Fields to Configure
Field | Example Value | Description |
---|---|---|
Pattern | ^([^/]+)/([^/]+)/?$ |
Defines the URL structure to match. |
Query Vars (JSON Format) | {"category":1,"tag":2} |
Maps URL parameters to WordPress query variables. |
Exclude CPT | Default Unchecked | Excludes CPTs (Custom Post Types) from conflicts. |
Step 2: Understanding Exclude CPT Option
By enabling the "Exclude CPT" option, you can prevent conflicts between default WordPress URLs and custom rewrite rules.Example Conflict Issue
Without Exclude CPT, both of these URLs may conflict because they share the same pattern:- WordPress Default URL:
https://www.example.com/listing/artisan-bakers/
- Custom Pattern URL (Rewrite Rule Applied):
https://www.example.com/financial-institutions/artisan/
listing/([^/]+)/([^/]+)/?$
, there is no need to check this checkbox.
Step 3: Apply the Rewrite Rule
Once you've specified the pattern and query variables, follow these steps:- Go to
Dashboard → QuickBuildWP
. - Click "Update Rewrite Rules" to save and apply your changes.
- QuickBuildWP registers the rewrite rules.
- WordPress flushes the rewrite cache to ensure new rules take effect.
- Your URLs now follow the new custom structure.
Step 4: Use the Correct Template
Once a rewrite rule is applied, QuickBuildWP will automatically map it to the archive.php template.Template Naming Convention
- If the field group name is
listing
, the system will use the template:listing-archive.php
news
, QuickBuildWP will expect:
news-archive.php
Troubleshooting Rewrite Rules in QuickBuildWP
If your rewrite rules are not working, follow these troubleshooting steps to resolve common issues.Flush Rewrite Rules Manually
Sometimes, WordPress does not recognize new rewrite rules immediately. To force WordPress to update them:- Go to
Dashboard → Settings → Permalinks
. - Click the "Save Changes" button, even if you don't change anything.
- Check your URLs again.
- WordPress rebuilds its internal URL structure.
- Ensures that new rewrite rules take effect.