“SAVE PERMALINKS” does more than FLUSH_REWRITE_RULES?
“SAVE PERMALINKS” does more than FLUSH_REWRITE_RULES?
“SAVE PERMALINKS” does more than FLUSH_REWRITE_RULES?
how to have same rewrite rules for 2 different post type?
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’ );
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
I have tested your code and it works just fine. The thing that I think you are missing is flushing the permalinks by going to WP Admin -> Settings -> Permalinks and click Save Changes.
Rewrite Rules, Query Vars and Pagination
WordPress matching URLs with trailing tildes code correction
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
I figured out that the problem above is related to the Divi & Extra theme that is being used. That theme has it’s own functions and registered the post formats in its own way, adding “et” in front of post format. Bellow this is shown, it solved the specific issue mentioned above: if ( is_object($post) … Read more
You can not realistically do such a thing. WordPress URL parsing is just not “smart” enough to be able to handle different types of content under the same “prefix”. WordPress will either try to parse the URLs as product or categories, depending on the specific order they are found in the rewrite table, and will … Read more