I use WordPress with Custom Post Types and Custom Taxonomies.
Problem
I try to create a post with the path /nyheter/bolag/post/
but it gets redirected to /bolag/post/
. It’s because I have a Custom Post Type with the slug bolag
and WP probably try to correct the path.
How is this solved? Code, plugins?
Code placed in functions.php
<?php
add_action( 'init', 'create_post_type' );
add_action( 'init', 'register_taxonomies' );
function create_post_type() {
$args_bolag = array(
'labels' => array(
'name' => 'Bolag',
'singular_name' => 'Bolag'
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'bolag'),
);
$args_nyheter = array(
'labels' => array(
'name' => 'Nyheter',
'singular_name' => 'Nyheter'
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'nyheter'),
);
register_post_type( 'bolag', $args_bolag );
register_post_type( 'nyheter', $args_nyheter );
}
function register_taxonomies()
{
$args_firma = array(
'label' => __( 'Firma' ),
'rewrite' => array( 'slug' => 'nyheter/bolag' ),
'hierarchical' => true,
);
register_taxonomy( 'firma', 'nyheter', $args_firma );
}