permastruct for custom post type not working in one of four cases
You’re currently placing your rewrite rules in the global scope, which means they execute as soon as your file is loaded, which may be too early. Instead try adding them on the init hook, or rewriting them to use the generate_rewrite_rules filter instead, e.g.: add_action(‘generate_rewrite_rules’, ‘themes_dir_add_rewrites’); function themes_dir_add_rewrites() { $theme_name = next(explode(‘/themes/’, get_stylesheet_directory())); global $wp_rewrite; … Read more