Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Paul Clark

    (@pdclark)

    • Edit the taxonomy under Edit Pod > Advanced Options > Custom Rewrite Slug, set the value to /home-decor/collections (without a trailing slash).
    • Save Permalinks under Settings > Permalinks. You’ll probably have an issue where if you try to view one of the Collections now, it will say 404. If this happens, it is because the rewrite rule for the Custom Post Type is matching before the Taxonomy. If that’s the case, add the below code to a plugin or your theme’s functions.php, then save Permalinks again to resolve it.
    add_filter('rewrite_rules_array', function($rules) {
    	$keys = array_keys($rules);
    	foreach ( $keys as $rule ) {
    		if (
    			false !== strpos( $rule, 'home-decor/' )
    			&& false === strpos( $rule, 'collections' )
    		) {
    			$value = $rules[ $rule ];
    			unset( $rules[ $rule ] );
    			$rules[ $rule ] = $value;
    		}
    	}
    	return $rules;
    });

    See https://wordpress.stackexchange.com/questions/282423/custom-post-type-rewrite-rules-not-working-how-to-alter-the-rewrite-order

    • This reply was modified 3 years, 4 months ago by Paul Clark.
    Thread Starter faizzsheikh

    (@faizzsheikh)

    I just did the Custom Rewrite Slug and its working fine. Thanks a lot Paul! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hierarchical Taxonomy URL that include Post Type’ is closed to new replies.