CPT slug as child of normal page

I have a new project that wants to use custom post types in WordPress as follows:

Mediathek (normal page as overview - http://mydomain.com/mediathek/)
> Webinare (CPT archive - http://mydomain.com/mediathek/webinar/)
>> Webinar 1...10 (posts within the CPT - http://mydomain.com/mediathek/webinar/webinar-1)
> Downloads (CPT archive - http://mydomain.com/mediathek/download/)
> Manuals (CPT archive - http://mydomain.com/mediathek/manual/)

I have successfully created the CPTs (lazy way using Toolset Types) but I struggle to figure out how to change the slug of the custom post types to be children of http://mydomain.com/mediathek/.

Any help appreciated.

Kevin

    • Luke

      Hi Kasia,
      I found this thread and I'm curious on how to implement the final result Kevin mentioned. I've been struggling with this for quite some time. I am using the CPT UI plugin and here is my code output for the Custom Post Type:

      function cptui_register_my_cpts_catalog() {
      
      	/**
      	 * Post Type: Catalog Items.
      	 */
      
      	$labels = array(
      		"name" => __( "Catalog Items", "custom-post-type-ui" ),
      		"singular_name" => __( "Catalog", "custom-post-type-ui" ),
      	);
      
      	$args = array(
      		"label" => __( "Catalog Items", "custom-post-type-ui" ),
      		"labels" => $labels,
      		"description" => "",
      		"public" => true,
      		"publicly_queryable" => true,
      		"show_ui" => true,
      		"delete_with_user" => false,
      		"show_in_rest" => true,
      		"rest_base" => "",
      		"rest_controller_class" => "WP_REST_Posts_Controller",
      		"has_archive" => true,
      		"show_in_menu" => true,
      		"show_in_nav_menus" => true,
      		"exclude_from_search" => false,
      		"capability_type" => "post",
      		"map_meta_cap" => true,
      		"hierarchical" => true,
      		"rewrite" => array( "slug" => "catalog", "with_front" => true ),
      		"query_var" => true,
      		"menu_position" => 5,
      		"supports" => array( "title", "thumbnail" ),
      		"taxonomies" => array( "category", "post_tag" ),
      	);
      
      	register_post_type( "catalog", $args );
      }
      
      add_action( 'init', 'cptui_register_my_cpts_catalog' );

      My custom taxonomy:

      function cptui_register_my_taxes_media_category() {
      
      	/**
      	 * Taxonomy: Media Category.
      	 */
      
      	$labels = array(
      		"name" => __( "Media Category", "custom-post-type-ui" ),
      		"singular_name" => __( "Media Category", "custom-post-type-ui" ),
      	);
      
      	$args = array(
      		"label" => __( "Media Category", "custom-post-type-ui" ),
      		"labels" => $labels,
      		"public" => true,
      		"publicly_queryable" => true,
      		"hierarchical" => true,
      		"show_ui" => true,
      		"show_in_menu" => true,
      		"show_in_nav_menus" => true,
      		"query_var" => true,
      		"rewrite" => array( 'slug' => 'media', 'with_front' => false,  'hierarchical' => true, ),
      		"show_admin_column" => true,
      		"show_in_rest" => false,
      		"rest_base" => "media_category",
      		"rest_controller_class" => "WP_REST_Terms_Controller",
      		"show_in_quick_edit" => true,
      		);
      	register_taxonomy( "media_category", array( "catalog" ), $args );
      }
      add_action( 'init', 'cptui_register_my_taxes_media_category' );

      But my slugs are not showing the way I want them :slight_frown: which is basically the same as what Kevin had mentioned.

      Right now our URL structure will not save the original category name from the custom post type, we lose it when we go to our custom taxonomy archive pages (taxonomy-media_category.php).
      Ex.
      sitename/category/

      but then it goes to. . .

      sitename/media/film, or sitename/media/album. We lose the original category (production, distribution).

      I attached to this message a txt file with a representation of what slug I'm going for. I have also been reading through this Jon Christopher article.

      Your help is very much appreciated! Let me know if you need more info.

      WP Permalinks:

      Some of the settings for the CPT UI custom post type:

      Some of the settings for the CPT UI custom taxonomy:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.