I am a little stuck with the following code I have done, the issue is as follows:
Custom Post-Type Page to use URL:
security/ssl-certificates/%ssl_brand%/[POST-TYPE-ITEM]
Custom Taxonomy I need to be accessible via URL:
security/ssl-certificates/[TAXONOMY]
I have been playing around but cannot seem to crack it for POST-TYPE, when I see the view links for the brands in the custom taxonomy they show as;
/security/ssl-certificates/geotrust (geotrust being the taxonomy brand)
so that seems to be fine but cannot get it working on the Post-Type URL, tried adding %ssl_brand% but shows as this;
security/ssl-certificates/%ssl_brand%/post-type-item-slug
See in the code below:
functions.php
function cptui_register_my_cpts_ssl_certificates() {
/**
* Post Type: SSL Certificates.
*/
$labels = array(
"name" => __( "SSL Certificates", "foxhost-child" ),
"singular_name" => __( "SSL Certificate", "foxhost-child" ),
"all_items" => __( "SSL Certificates", "foxhost-child" ),
"add_new" => __( "Add New SSL", "foxhost-child" ),
"add_new_item" => __( "Add New SSL", "foxhost-child" ),
"edit_item" => __( "Edit SSL", "foxhost-child" ),
"new_item" => __( "New SSL", "foxhost-child" ),
"view_item" => __( "View SSL", "foxhost-child" ),
"view_items" => __( "View All SSL's", "foxhost-child" ),
"search_items" => __( "Search SSL", "foxhost-child" ),
"not_found" => __( "No SSL's Found", "foxhost-child" ),
"not_found_in_trash" => __( "No SSL's found in Trash", "foxhost-child" ),
"parent_item_colon" => __( "security,products", "foxhost-child" ),
"parent_item_colon" => __( "security,products", "foxhost-child" ),
);
$args = array(
"label" => __( "SSL Certificates", "foxhost-child" ),
"labels" => $labels,
"description" => "SSL Certificate Products",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"show_in_rest" => false,
"rest_base" => "",
"has_archive" => false,
"show_in_menu" => "edit.php?post_type=products",
"show_in_nav_menus" => true,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => true,
"rewrite" => array( "slug" => "security/ssl-certificates/%ssl_brand%", "with_front" => false ),
"query_var" => "ssl_brand",
"menu_icon" => "dashicons-lock",
"supports" => array( "title", "editor", "revisions" ),
"taxonomies" => array( "ssl_brand" ),
);
register_post_type( "ssl_certificates", $args );
}
add_action( 'init', 'cptui_register_my_cpts_ssl_certificates' );
function cptui_register_my_taxes_ssl_brand() {
/**
* Taxonomy: SSL Brands.
*/
$labels = array(
"name" => __( "SSL Brands", "foxhost-child" ),
"singular_name" => __( "Brand", "foxhost-child" ),
);
$args = array(
"label" => __( "SSL Brands", "foxhost-child" ),
"labels" => $labels,
"public" => true,
"hierarchical" => false,
"label" => "SSL Brands",
"show_ui" => true,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"query_var" => true,
"rewrite" => array( 'slug' => 'security/ssl-certificates', 'with_front' => false, ),
"show_admin_column" => true,
"show_in_rest" => false,
"rest_base" => "ssl_brand",
"show_in_quick_edit" => false,
);
register_taxonomy( "ssl_brand", array( "ssl_certificates" ), $args );
}
add_action( 'init', 'cptui_register_my_taxes_ssl_brand' );