Change permalinks for posts & for custom post types

with_front=false is the key, but WordPress also seems to like to hard-cache the settings you originally register a CPT with. Try unregister_post_type() above the CPT registration so it’s completely removed and immediately added again from scratch with the with_front setting.

Display Current Posts Category (with the most posts)?

get_the_category() returns an array of WP_Term objects, so you already have access to the count property – just sort the array by it and retrieve the one with the highest count: $main_category = current( wp_list_sort( get_the_category(), [ ‘count’ => ‘DESC’ ] ) ); Check out the documentation for wp_list_sort()