How to make posts under custom post type not generate a URL / post

Looking at the class and function you’re using, this method is a little problematic: public function buildPostArgs( $slug, $singular=”Post”, $plural=”Posts”, $args = array() ) { $args = wp_parse_args($args, $this->postDefaults); $args[‘rewrite’][‘slug’] = $slug; $args[‘labels’] = $this->buildPostLabels($singular, $plural); return $args; } If we ignore your problem, $args[‘rewrite’][‘slug’] is going to generate a PHP warning if you set … Read more

IF taxonomy archive is hierarchical THEN

Look at the docs (please read the docs) for is_taxonomy_hierarchical(). You need to tell it which taxonomy you’re checking: if ( is_taxonomy_hierarchical( ‘my_taxonomy_name’ ) ) { } If you’re template isn’t specific to a taxonomy, and you need to know which taxonomy you’re viewing, use get_queried_object() to figure it out (you were already told how … Read more

URL rewrites af

Use add_rewrite_rule(). function wpse325663_rewrite_resource_type() { add_rewrite_rule(‘^resources\/(.+)/?’, ‘resources/?type=$matches[1]’, ‘top’); } add_action(‘init’, ‘wpse325663_rewrite_resource_type’); An important note from the codex: Do not forget to flush and regenerate the rewrite rules database after modifying rules. From WordPress Administration Screens, Select Settings -> Permalinks and just click Save Changes without any changes.