Create new URL structure for custom post types

Sorted in the end. As Milo suggested I didn’t need the calls to add_rewrite_tag. The following code works: /** * Custom rewrite rules */ function my_rewrite_rules() { add_rewrite_rule( ‘^([^/]*)/([^/]*)/([^/]*)?’, ‘index.php?post_type=room&room=$matches[3]’, ‘top’ ); add_rewrite_rule( ‘^([^/]*)/([^/]*)?’, ‘index.php?post_type=house_type&house_type=$matches[2]’, ‘top’ ); add_rewrite_rule( ‘^([^/]*)/?’, ‘index.php?post_type=development&development=$matches[1]’, ‘top’ ); } add_action( ‘init’, ‘my_rewrite_rules’ );

How to structure a website with custom post types and custom taxonomies?

What would actually be the content of such a page as http://www.example.com/{sport-name}/{category}/{category}/{team-name}? I can conceive of a team roster and statistics page, but only for a professional team. A sports club would be more geared toward needing to see the league schedule (time and location of next game), and perhaps win/loss record to feed into … Read more

How to get a clean pagination link without variable

Sure you retrieve link like site.com/page/?cp=2, because you added get parameter cp. If you wanna link like site.com/page/cp/2 – remove base parameter and set format to ?cp=%#% If you wanna link like site.com/page/2 – remove ‘base’ and ‘format’ parameters and stay it default. Because format – is ?page=%#% by default.

How to create a permalink structure with custom taxonomies and custom post types

I suspect the extra slash is coming from the str_replace action because normally there’s no need to manually add slashes when retrieving TAX urls. Since you now end up with 1 unwanted slash, I would recommend testing situations with/without the slash. Starting with removing the one in the function definition. Make it empty, see what … Read more

Some permalinks on Apache/localhost development setup return 404’s when set to anything other than plain permalinks

The slug you use for the CPT looks very weird. You should inspect the rewrite rules being used in parsing a request with something like the query monitor plugin, but the gut feeling is that your CPT slug makes all URLs to match it and since there is no CPT for the URL of a … Read more