WordPress Rewrite Rules Generator

Generate WordPress rewrite rules for custom post types, taxonomies, redirects, and custom regex patterns with copy-ready PHP.

WordPressMode: Custom Post Type

Custom Post Type URL

Preview/projects/my-project/

Quick Presets

Generated Code
<?php
/**
 * Custom Post Type Rewrite Rules
 * Post Type: project
 * Archive URL: /projects/
 * Single URL: /project/{slug}/
 *
 * Add to functions.php
 */

function register_project_post_type() {
    register_post_type( 'project', [
        'labels'      => [
            'name'          => ucfirst( 'projects' ),
            'singular_name' => ucfirst( 'project' ),
        ],
        'public'      => true,
        'has_archive' => 'projects',
        'rewrite'     => [
            'slug'       => 'project',
            'with_front' => false,
            'feeds'      => false,
            'pages'      => true,
        ],
        'supports'    => [ 'title', 'editor', 'thumbnail', 'excerpt' ],
        'show_in_rest'=> true,
    ] );
}
add_action( 'init', 'register_project_post_type' );

function project_activation() {
    register_project_post_type();
    flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'project_activation' );

function add_project_rewrite_rules() {
    add_rewrite_rule(
        '^projects/page/([0-9]+)/?$',
        'index.php?post_type=project&paged=$matches[1]',
        'top'
    );
}
add_action( 'init', 'add_project_rewrite_rules' );
After adding rewrite code, flush WordPress permalinks once from Settings > Permalinks.

Usage Tips

Use the rewrite argument on register_post_type when a simple slug change is enough.
Custom query vars used inside index.php targets must be added through query_vars.

Top vs Bottom

Most custom rewrite rules should be added at the top so WordPress checks them before its default permalink rules.

Register Query Vars

If you add custom query variables in the rewrite target, remember to register them with the query_vars filter.

Flush Permalinks

After saving rewrite code, flush rules by visiting Settings > Permalinks and clicking Save Changes once.

Technologies

Our Tech Stack

FigmaFigma
React.jsReact.js
Next.jsNext.js
TypeScriptTypeScript
ShopifyShopify
WordPressWordPress
HTML5HTML5
CSS3CSS3
TailwindTailwind
FramerFramer
FigmaFigma
React.jsReact.js
Next.jsNext.js
TypeScriptTypeScript
ShopifyShopify
WordPressWordPress
HTML5HTML5
CSS3CSS3
TailwindTailwind
FramerFramer
FigmaFigma
React.jsReact.js
Next.jsNext.js
TypeScriptTypeScript
ShopifyShopify
WordPressWordPress
HTML5HTML5
CSS3CSS3
TailwindTailwind
FramerFramer
PHPPHP
GitGit
MySQLMySQL
AWS/VercelAWS/Vercel
IllustratorIllustrator
PhotoshopPhotoshop
SassSass
Node.jsNode.js
StripeStripe
GraphQLGraphQL
PHPPHP
GitGit
MySQLMySQL
AWS/VercelAWS/Vercel
IllustratorIllustrator
PhotoshopPhotoshop
SassSass
Node.jsNode.js
StripeStripe
GraphQLGraphQL
PHPPHP
GitGit
MySQLMySQL
AWS/VercelAWS/Vercel
IllustratorIllustrator
PhotoshopPhotoshop
SassSass
Node.jsNode.js
StripeStripe
GraphQLGraphQL