Hi all,
I am trying to create a custom Post Type and Taxonomy that will work with the permalink structure of: /mod-slug/taxonomy-name/child-taxonomy-name/post-name
However, with the following code, I am only able to access posts like the following:
/slug/post-name
I was wondering if someone could point out what I have done wrong here
<?php
/*
* Plugin Name: Mod post type
* Version: 1.0.
* Plugin URI:
* Description: A custom posttype to facilitate modifications
* Author: Jake
* Author URI:
* Requires at least: 3.9
* Tested up to: 4.2.1
*
* @package WordPress
* @author Jake
* @since 1.0.0
*/
if ( ! function_exists('register_mod_posttype') ) {
function create_my_taxonomies() {
register_taxonomy(
'rw_mod_category',
'rw_mod_post',
array(
'labels' => array(
'name' => 'Mod Categories',
'add_new_item' => 'Add New Mod Category',
'new_item_name' => "New Mod Category"
),
'rewrite' => array(
'slug' => 'mods', // This controls the base slug that will display before each term
'with_front' => true, // Don't display the category base before "/locations/"
'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
),
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true
)
);
}
// Register Custom Post Type
function register_mod_posttype() {
$labels = array(
'name' => _x( 'Mods', 'Post Type General Name', 'mods_domain' ),
'singular_name' => _x( 'Mod', 'Post Type Singular Name', 'mods_domain' ),
'menu_name' => __( 'Mod', 'mods_domain' ),
'name_admin_bar' => __( 'Mods', 'mods_domain' ),
'parent_item_colon' => __( 'Parent Mod:', 'mods_domain' ),
'all_items' => __( 'All Mods', 'mods_domain' ),
'add_new_item' => __( 'Add New Mod', 'mods_domain' ),
'add_new' => __( 'Add New', 'mods_domain' ),
'new_item' => __( 'New Mod', 'mods_domain' ),
'edit_item' => __( 'Edit Mod', 'mods_domain' ),
'update_item' => __( 'Update Mod', 'mods_domain' ),
'view_item' => __( 'View Mod', 'mods_domain' ),
'search_items' => __( 'Search Mod', 'mods_domain' ),
'not_found' => __( 'Not found', 'mods_domain' ),
'not_found_in_trash' => __( 'Not found in Trash', 'mods_domain' ),
);
$args = array(
'label' => __( 'mod', 'mods_domain' ),
'description' => __( 'Mods being posted to the site', 'mods_domain' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'revisions', 'custom-fields', 'page-attributes', ),
'taxonomies' => array( 'rw_mod_category', 'post_tag' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-admin-tools',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
'rewrite' => array('slug' => 'mods'),
);
register_post_type( 'rw_mod_post', $args );
}
// Hook into the 'init' action
add_action( 'init', 'register_mod_posttype', 0 );
add_action( 'init', 'create_my_taxonomies', 0 );
}
Any help would be greatly appreciated,
Jake