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’ );

Pretty links with add_rewrite_rule and add_query_var

There are a couple of issues with your regular expression: ^model_more/(\d*)$ ^— Says “match start of line” In your URLs, the start of the line is actually /model/, so ^model_more will never match. Instead, try a regex like this: ^model/[^/]+/model_more/(\d+)/?$ [^/]+ says “match anything except /, since I would guess there are multiple models under … Read more

Rewrite rule for post as a child of a CPT

In addition to setting has_archive you need to set rewrite when you define the CPT. I replaced $archives because your code snippet does not have it defined. $rewrite = array(‘slug’ => ‘my-cpt-type’, ‘with_front’ => false); $download_args = array( ‘labels’ => $labels, ‘public’ => true, ‘publicly_queryable’=> true, ‘show_ui’ => true, ‘show_in_menu’ => true, ‘query_var’ => true, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)