wordpress category rewrite rule with pagination

I was able to solve it doing these rewrites in the following order. So I specified 3 category url in the beginning then 2 category url below that and in the and single category url /combine/brand/category1/category2/page/1-9/ add_rewrite_rule( ‘^combine/([^/]*)/([^/]*)/([^/]*)/page/([0-9]*)$/’,’index.php?category_name=$matches[1]+$matches[2]+$matches[3]&paged=$matches[4]’, ‘top’ ); /combine/brand/category1/page/1-9 add_rewrite_rule( ‘^combine/([^/]*)/([^/]*)/page/([0-9]*)$’,’index.php?category_name=$matches[1]+$matches[2]&paged=$matches[3]’, ‘top’ ); /combine/brand/category1/ add_rewrite_rule( ‘^combine/([^/]*)/?([^/]*)/([^/]*)/?’,’index.php?category_name=$matches[1]+$matches[2]+$matches[3]’, ‘top’ );

WordPress picks a wrong template if ?cat= is used as URL parameter

Why? This is because the pretty permalink: /tag/online-lectures/?cat=7 gets translated to the ugly permalink: index.php?tag=online-lectures&cat=7 And as you can see the /tag/online-lectures part no longer has the emphasis it once had. Afterall /category/arrester?tag=online-lectures would boil down to exactly the same ugly URL. Since the resulting query is an archive, and the most specific template available … Read more

Custom rewrite, url path with parameters to a page

Your code seems to work fine with slight modifications. Taken from here: https://developer.wordpress.org/reference/functions/add_rewrite_rule/#comment-content-4787 First off, I moved the rewrite rules to init and modified the regex to match parameters optionally: function wse_414800_rewrite_state_city() { add_rewrite_rule( ‘^(pluginpage)/([^/]*)/([^/]*)/?’, ‘index.php?pagename=pluginpage&state=$matches[2]&city=$matches[3]’, ‘top’ ); add_rewrite_rule( ‘^(pluginpage)/([^/]*)/?’, ‘index.php?pagename=pluginpage&state=$matches[2]’, ‘top’ ); } add_action(‘init’, ‘wse_414800_rewrite_state_city’); And, to be able to retrieve our custom query … Read more

Rewrite rule taxonomy url with different values in one function

You can do that using a subpattern or capturing group like ([a-z]) in your rewrite rule’s regex (i.e. regular expression pattern, which is the 1st parameter for add_rewrite_rule()), and then use $matches[<n>] in your query (the 2nd parameter for add_rewrite_rule()), where <n> is a number (1 or above) and it’s the subpattern’s position number. Why … Read more

Custom slugs with dates & IDs on Custom Post Type

Yes, it’s not hard to do that. Just register your post type and enable rewriting for that post type, i.e. set rewrite to true. Once registered, modify its permalink structure like so: global $wp_rewrite; $wp_rewrite->extra_permastructs[‘<post type>’][‘struct’] = ‘<your structure here>’; Use the post_type_link filter to replace rewrite tags like %post_id% in the permalink URL. If … Read more

Using a variable in page permalink

As I said, the permalink changes from YEAR_NAME to 2023, but the link gets 404 error Yes, and it’s because the post slug no longer matched the value in the database (in the wp_posts table, column post_name), hence the permalink URL became invalid and WordPress displayed a 404 error page. So you need to add … Read more

What is the best way to relate different custom post types?

I think a better approach for this would be to create a single nested (hierarchical) custom post type. For example, it can be series. Then a single series named sample-series as a top level post of series post type: site.com/series/sample-series/. Then seasons named season-one, season-two etc. can be children of sample-series, like: site.com/series/sample-series/season-one, site.com/series/sample-series/season-two. Similarly, … Read more