Rewrite Custom Post Type(with taxonomies) URL - wordpress

I have a Custom Post Type with 1 taxonomy and this is the link structure:
mywebsite.com/casos-legal (Show the post in archive-casos-legal.php)
And when I click on any post:
mywebsite.com/casos-legal/lima/this-is-the-post-title
In the case above, "lima" is a term of the taxonomy.
Is there a way to add a path before "casos-legal"? something like this:
mywebsite.com/temas/legal/casos-legal
and:
mywebsite.com/temas/legal/casos-legal/lima/this-is-the-post-title
And much better, change the post slug for just "casos" to get something like this:
mywebsite.com/temas/legal/casos/lima/this-is-the-post-title
Thank in advance!
This is how it looks the CTP
function aprodeh_casos(){
$labels = array(
'name' => 'Casos - legal',
'singular_name' => 'Caso',
'add_new' => 'Agregar',
'all_items' => 'Todos',
'add_new_item' => 'Agregar',
'edit_item' => 'Editar',
'new_item' => 'Nuevo',
'view_item' => 'Ver',
'search_item' => 'Buscar',
'not_found' => 'No se encontraron casos',
'not_found_in_trash' => 'No se encontraron casos en la papelera',
'parent_item_colon' => 'Parent Item',
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'query_var' => true,
'rewrite' => array( 'slug' => '/casos-legal/%categoria_casos%', 'with_front' => false ),
'has_archive' => 'casos-legal',
'capability_type' => 'post',
'hierarchical' => false,
'supports' => array(
'title',
'editor',
'thumbnail',
),
'menu_position' => 5,
'exclude_from_search' => false,
'taxonomies' => array('post_tag'),
);
register_post_type('casos-legal',$args);
} add_action('init','aprodeh_casos');
This is how it looks the Taxonomy:
function aprodeh_casos_taxonomia(){
$labels = array(
'name' => 'Categorías',
'singular_name' => 'Categoría',
'search_items' => 'Buscar categoría',
'all_items' => 'Todas las categorías',
'edit_item' => 'Editar categoría',
'update_item' => 'Actualizar categoría',
'add_new_item' => 'Agregar categoría',
'new_item_name' => 'Nuevo categoría',
'menu_name' => 'Categorías',
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'casos-legal', 'with_front' => false ),
);
register_taxonomy('categoria_casos', array('casos-legal'), $args);
}
add_action('init', 'aprodeh_casos_taxonomia');
And finally, this code in order to get this link structure:
mywebsite.com/casos-legal/lima/this-is-the-post-title
function wpa_casos_permalinks( $post_link, $post ){
if ( is_object( $post ) && $post->post_type == 'casos-legal' ){
$terms = wp_get_object_terms( $post->ID, 'categoria_casos' );
if( $terms ){
return str_replace( '%categoria_casos%' , $terms[0]->slug , $post_link );
}
}
return $post_link;
}
add_filter( 'post_type_link', 'wpa_casos_permalinks', 1, 2 );

Try updating
'rewrite' => array( 'slug' => '/casos-legal/%categoria_casos%', 'with_front' => false ),
to
'rewrite' => array( 'slug' => '/tema/legal/casos/%categoria_casos%', 'with_front' => false ),

Related

translate slug of custom post type with translatepress

How can I make the slug of a custom post type translate?
I have mysite.com/product in my main language, and in the second I want to show mysite.com/es/producto
I try with this without success
function create_posttype_product() {
if ($language == 'sv') {
$productSlug = 'produkter';
} else {
$productSlug = 'product';
}
register_post_type( 'product',
array(
'labels' => array(
'name' => __('Products'),
'singular_name' => __('product'),
'add_new' => __('Add new product'),
'add_new_item' => __('New product'),
'edit_item' => __('Edit product')
),
'public' => true,
'rewrite' => array( 'slug' => $productSlug, 'with_front' => false ),
'has_archive' => 'product',
'menu_icon' => 'dashicons-editor-help',
'supports' => array('title', 'editor', 'thumbnail')
)
)};
add_action( 'init', 'create_posttype_product' );

How to add 2 different taxonomies to Wordpress CPT permalink structure

I have problem to add a second taxonomy to my cpt permalink structure.
With one register_taxonomy (pxlr-products-category) everything works fine and looks like this: https://example.com/products/my_category/my_productname
But I want a second register_taxonomy (pxlr-products-status). When I do that I see in my permalink instead of the tax slug just this %status% https://example.com/products/my_category/%status%/my_productname and I get an 404 error. Of cause I'ved flushed my permalinks
A second thing is, (pxlr-products-status) can have a value like (discontinued) but it is not a must, it can be empty as well
My permalinks should look like this https://example.com/products/my_category/my_status/my_productname
Or look like this https://example.com/products/my_category/my_productname
Here is my CPT, I can't find my error and need help, thanks :-/
class PXLR_Products
{
function __construct(){
// register post type
add_action('init', array($this, 'register_products_post_type'));
// register taxonomy
add_action('init', array($this, 'register_products_taxonomy'));
// slug - category filter
add_filter('post_type_link', [$this,'products_post_link'], 1, 3 );
// Rewrite support
add_action('init', [$this, 'custom_rewrite_rules']);
}
function custom_rewrite_rules() {
add_rewrite_rule(
'products/(.+?)/?$',
'index.php?pxlr-products-category=$matches[1]',
'bottom');
// add_rewrite_rule(
// 'products/(.+?)/(.+?)/?$',
// 'index.php?pxlr-products-category=$matches[1]&pxlr-products-status=$matches[2]',
// 'bottom');
}
public function register_products_post_type()
{
$labels = array(
'name' => _x('Products', 'Post Type General Name', 'pxlr-products'),
'singular_name' => _x('Products', 'Post Type Singular Name', 'pxlr-products'),
'menu_name' => __('PXLR Products', 'pxlr-products'),
'all_items' => __('All Products', 'pxlr-products'),
'view_item' => __('Show product', 'pxlr-products'),
'add_new_item' => __('Add product', 'pxlr-products'),
'add_new' => __('Add Product', 'pxlr-products'),
'edit_item' => __('Edit product', 'pxlr-products'),
'update_item' => __('Update product', 'pxlr-products'),
'search_items' => __('Search products', 'pxlr-products'),
'not_found' => __('No products found', 'pxlr-products'),
'not_found_in_trash' => __('No products found in trash.', 'pxlr-products'),
);
$args = array(
'labels' => $labels,
'name' => 'Products',
'name_admin_bar' => 'Products',
'singular_name' => 'Products',
'menu_icon' => 'dashicons-microphone',
'label' => __('Products', 'pxlr-products'),
'hierarchical' => true,
'show_in_menu' => true,
'show_in_rest' => true,
'show_in_nav_menus' => false,
'menu_position' => 28,
'supports' => array('title', 'editor', 'revisions', 'thumbnail', 'page-attributes', 'excerpt', 'custom-fields'),
'rest_base' => 'products',
'public' => true,
'show_ui' => true,
'has_archive' => 'products',
'can_export' => false,
'taxonomies' => array('pxlr-products-category', 'pxlr-products-status'),
'publicaly_queryable' => true,
'query_var' => true,
'exclude_from_search' => false,
//'rewrite' => ['slug' => _x('products/%category%', 'Post Type Slug', 'pxlr-products'), 'with_front' => true ], // for one taxonomy if working fine!!!!
'rewrite' => ['slug' => _x('products/%category%/%status%', 'Post Type Slug', 'pxlr-products'), 'with_front' => true ], // for two taxonomies
'template_lock' => 'all',
);
register_post_type('pxlr-products', $args);
}
public function products_post_link( $post_link, $id = 0 ){
$post = get_post($id);
if ( is_object( $post ) ){
$terms = wp_get_object_terms( $post->ID, 'pxlr-products-category' );
if( $terms ){
return str_replace( '%category%' , $terms[0]->slug , $post_link );
}
$terms = wp_get_object_terms( $post->ID, 'pxlr-products-status' );
if( $terms ){
return str_replace( '%status%' , $terms[0]->slug , $post_link );
}
}
return $post_link;
}
public function register_products_taxonomy()
{
register_taxonomy(
'pxlr-products-category',
'pxlr-products',
array(
'label' => __('Categories Product', 'pxlr-products'),
'hierarchical' => true,
'with_front' => false,
'show_in_rest' => true,
'rewrite'=> ['slug' => _x('products', 'Category Slug', 'pxlr-products'),
'with_front' => false,
'hierarchical' => true
],
'show_admin_column' => true,
'show_in_nav_menus' => true,
'has_archive' => true,
)
);
register_taxonomy(
'pxlr-products-status',
'pxlr-products',
array(
'label' => __('Status Product', 'pxlr-products'),
'hierarchical' => true,
'with_front' => false,
'show_in_rest' => true,
'rewrite'=> ['slug' => _x('products/%category%', 'Status Slug', 'pxlr-products'),
'with_front' => false,
'hierarchical' => true
],
'show_admin_column' => true,
'show_in_nav_menus' => true,
'has_archive' => true,
)
);
}
}

Wordpress custom post type with custom taxonomy slug

I created custom post type with custom taxonomy. Its working, but i am facing one issue is
http://example.com/taxonomy-slug/%term%/post-title this is my custom post type url
exg:
http://example.com/boat-hire/party-boats/bmw-z4
Here
boat-hire -> taxonomy-slug
party-boats -> taxonomy-term
bmw-z4 -> product title
custom-post-type slug -> products/%custom_taxonomy%
this link is working, but also its working when i change taxonomy term value
Exg: http://example.com/boat-hire/paty-bts/bmw-z4
This link also working even after changing(party-boats -> paty-bts) or put any value at that position. Actually it should be redirect to page not found page.
I have listed my code below
Custom Post Type:
<?php
function create_boat_posttype() {
$supports = array(
'title',
'editor',
'thumbnail',
'excerpt',
// 'custom-fields',
// 'revisions'
);
$labels = array(
'name' => _x('Boats', 'plural'),
'singular_name' => _x('Boat', 'singular'),
'menu_name' => _x('Boats', 'admin menu'),
'name_admin_bar' => _x('Boat', 'admin bar'),
'add_new' => _x('Add Boat', 'add new'),
'add_new_item' => __('Add New Boat'),
'new_item' => __('New Boat'),
'edit_item' => __('Edit Boat'),
'view_item' => __('View Boat'),
'all_items' => __('All Boats'),
'search_items' => __('Search Boat'),
'not_found' => __('No boats found.'),
);
$args = array(
'supports' => $supports,
'labels' => $labels,
'public' => true,
'query_var' => 'my_boat_hire',
'rewrite' => array( 'slug' => 'boat-hire/%boat_term%','with_front' => false, 'hierarchical' => true ),
'taxonomies' => array( 'boat_term' ),
'has_archive' => true,
'hierarchical' => false,
);
register_post_type('boat', $args);
}
add_action( 'init', 'create_boat_posttype' );
Custom Taxonomy:
add_action( 'init', 'create_boat_taxonomies', 0 );
if(!function_exists('create_boat_taxonomies'))
{
function create_boat_taxonomies() {
$labels = array(
'name' => __('Boat Categories'),
'singular_name' => __('Boat Category'),
'search_items' => __('Search Boat Categories'),
'all_items' => __('All Boat Categories'),
'parent_item' => __('Parent'),
'parent_item_colon' => __('Parent:'),
'edit_item' => __('Edit Boat Category'),
'update_item' => __('Update Boat Category'),
'add_new_item' => __('Add New Boat Category'),
'new_item_name' => __('New Boat Category'),
'menu_name' => __('Boat Categories'),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => 'boat_category',
'rewrite' => array( 'slug' => 'boat-hire',
'with_front' => false ),
);
register_taxonomy( 'boat_term', array( 'boat' ), $args );
}
}
function filter_boat_type_link($link, $post)
{
if ($post->post_type != 'boat')
return $link;
if ($cats = get_the_terms($post->ID, 'boat_term'))
$link = str_replace('%boat_term%', array_pop($cats)->slug, $link);
return $link;
}
add_filter('post_type_link', 'filter_boat_type_link', 10, 2);

Remove custom post type slug from wordpress url and keep taxonomy term

I have registered CPT & taxonomy with the following code :
// CPT & Taxonomy
add_action('init', 'marques_cpt');
function marques_cpt() {
$labels = array(
'name' => 'Marques',
'singular_name' => 'Marque',
'add_new' => 'Ajouter',
'add_new_item' => 'Ajouter Marque',
'edit_item' => 'Modifier Marque',
'new_item' => 'Nouvelle Marque',
'all_items' => 'Toutes les Marques',
'view_item' => 'Afficher Marque',
'search_items' => 'Rechercher Marques',
'not_found' => 'Pas de marques',
'not_found_in_trash' => 'Pas de marques',
'parent_item_colon' => '',
'menu_name' => 'Marques'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'taxonomies' => array('marquecategory'),
'rewrite' => array('slug' => 'marque/%marquescategory%', 'with_front' => false),
'capability_type' => 'post',
'has_archive' => 'marques',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt'),
);
register_post_type('marque', $args);
$labels = array(
'name' => 'Marques Catégories',
'singular_name' => 'Marques',
'search_items' => 'Rechercher Marques Catégories',
'all_items' => 'Toutes Catégories',
'parent_item' => 'Parent Catégories',
'parent_item_colon' => 'Parent Catégories Marques:',
'edit_item' => 'Modifier Catégories Marques',
'update_item' => 'Mettre à jour Catégories Marques',
'add_new_item' => 'Ajouter Catégories Marques',
'new_item_name' => 'Nouvelle Catégories Marques',
);
$args = array(
'hierarchical' => true,
'rewrite' => array('slug' => 'marque'),
'show_in_nav_menus' => true,
'labels' => $labels
);
register_taxonomy('marquescategory', 'marque', $args);
unset($labels);
unset($args);
}
add_filter('post_type_link', 'marquecategory_permalink_structure', 10, 4);
function marquecategory_permalink_structure($post_link, $post, $leavename, $sample) {
if (false !== strpos($post_link, '%marquescategory%')) {
$projectscategory_type_term = get_the_terms($post->ID, 'marquescategory');
if (!empty($projectscategory_type_term))
$post_link = str_replace('%marquescategory%', array_pop($projectscategory_type_term)->
slug, $post_link);
else
$post_link = str_replace('%marquescategory%', 'non-selectione', $post_link);
}
return $post_link;
}
this code return the url : domain.come/marque/taxonomy-term/post-slug
I need to remove the CPT slug 'marque' from the url & keep the taxonomy term : domain.come/taxonomy-term/post-slug
i have managed to do that by removing 'marque/' from rewrite :
'rewrite' => array('slug' => 'marque/%marquescategory%', 'with_front' => false),
it works perfectly but when i did that, the other simple posts and pages returns 404 page!!

How to create custom post types in WordPress?

I want to know the procedure of how to create custom post types with WordPress. I will be thankful if anyone help me with complete procedure of code and plugins. I will also be writing a blog post regarding this issue and I need help from top contributors of Stackoverflow.
Add code similar to this to your functions.php
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'your_custom_name',
array(
'labels' => array(
'name' => __( 'Custom_names' ),
'singular_name' => __( 'Custom_names' )
),
'public' => true,
'has_archive' => true,
)
);
}
after it you can see a another option in your dashbooard left bar to add custom post.
see more about Post Types
<?php
require_once 'wp-load.php'; //path of wp-load.php
$name = 'my post';
$content = 'dummy Content here';
$featured_image = 'fullimage url.jpg'; //pass here full image url
$post_data = array(
'post_title' => wp_strip_all_tags( $name ),
'post_content' => $content,
'post_status' => 'publish',
'post_type' => 'post',
'post_author' => 1,
'post_category' => array(1,2),
'page_template' => ''
);
$post_id = wp_insert_post( $post_data, $error_obj );
// for custom field
//add_post_meta( $post_id, 'post_date', 'Dec 5, 2018' ); // second parameter is your custom field name, 3rd parameter is value
generate_Featured_Image($featured_image, $post_id );
function generate_Featured_Image( $image_url, $post_id ){
$upload_dir = wp_upload_dir();
$image_data = file_get_contents($image_url);
$filename = basename($image_url);
if(wp_mkdir_p($upload_dir['path']))
$file = $upload_dir['path'] . '/' . $filename;
else
$file = $upload_dir['basedir'] . '/' . $filename;
file_put_contents($file, $image_data);
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_title' => sanitize_file_name($filename),
'post_content' => '',
'post_status' => 'inherit'
);
$attach_id = wp_insert_attachment( $attachment, $file, $post_id );
require_once(ABSPATH . 'wp-admin/includes/image.php');
$attach_data = wp_generate_attachment_metadata( $attach_id, $file );
$res1= wp_update_attachment_metadata( $attach_id, $attach_data );
$res2= set_post_thumbnail( $post_id, $attach_id );
echo 'post created...';
}
?>
function my_custom_event() {
$labels = array(
'name' => _x( 'Events', 'post type general name' ),
'singular_name' => _x( 'Events', 'post type singular name' ),
'add_new' => _x( 'Add New', 'Events' ),
'add_new_item' => __( 'Add New Events' ),
'edit_item' => __( 'Edit Events' ),
'new_item' => __( 'New Events' ),
'all_items' => __( 'All Events' ),
'view_item' => __( 'View Events' ),
'search_items' => __( 'Search Events' ),
'not_found' => __( 'No Events found' ),
'not_found_in_trash' => __( 'No Events found in the Trash' ),
'parent_item_colon' => '',
'menu_name' => 'Events'
);
$args = array(
'labels' => $labels,
'description' => 'Events',
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'menu_position' => 5,
'supports' => array( 'title' , 'thumbnail', 'editor', 'page-attributes'),
'has_archive' => true,
);
register_post_type( 'event', $args );
}
add_action( 'init', 'my_custom_event' );
## This is my full working code for creating custom post types ##
function slide_init()
{
$labels = array(
'name' => 'Slider',
'singular_name' => 'Slider',
'menu_name' => 'Slider',
'name_admin_bar' => 'Slider',
'add_new' => 'Add New Slider',
'add_new_item' => 'Add New Slider',
'new_item' => 'New Slider',
'edit_item' => 'Edit Slider',
'view_item' => 'View Slider',
'all_items' => 'All Slider Images',
'search items' => 'Search Slider',
'parent_item_colon' => 'Parent Slider',
'not_found' => 'No Slider Found',
'not_found_in_trash' => 'No Slider Found In Trash',
);
$args = array(
'labels' => $labels,
'public' => true,
'publicaly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'Slider' ),
'capability_type' => 'post',
'has_archive' => true,
'Hierarchical' => false,
'menu_position' => null,
'menu_icon' => 'dashicons-format-image',
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments','hierarchical','trackbacks','custom-fields','revisions','page-attributes'),
'taxonomies' =>array('category'),
);
register_post_type('Slider',$args);
register_taxonomy('Slider_category','Slider',array('hierarchical' => true, 'label' => 'Category', 'query_var' => true, 'rewrite' => array('slug' => 'slider-category')));
}
add_action('init','slide_init');
/** Meet the team custom post
You can use below WordPress script to create custom post type without any plugins */
$labels = array(
'name' => _x('Team', 'Team', 'Team') ,
'singular_name' => _x('Team', 'Team', 'rjis') ,
'menu_name' => _x('Meet the Team', 'admin menu', 'rjis') ,
'name_admin_bar' => _x('Team', 'add new on admin bar', 'rjis') ,
'add_new' => _x('Add New', 'Team', 'rjis') ,
'add_new_item' => __('Add New Team', 'rjis') ,
'new_item' => __('New Team', 'rjis') ,
'edit_item' => __('Edit Team', 'rjis') ,
'view_item' => __('View Team', 'rjis') ,
'all_items' => __('All Team Members', 'rjis') ,
'search_items' => __('Search Team', 'rjis') ,
'parent_item_colon' => __('Parent Team:', 'rjis') ,
'not_found' => __('No Team found.', 'rjis') ,
'not_found_in_trash' => __('No Team found in Trash.', 'rjis')
);
$args = array(
'labels' => $labels,
'description' => __('Description.', 'Meet the team') ,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array(
'slug' => 'team'
) ,
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'menu_position' => null,
'supports' => array(
'title',
'editor',
'author',
'thumbnail',
'excerpt'
) ,
'menu_icon' => PLUGIN_URL . "images/team.png"
);
register_post_type('team', $args);
Here Career word is Used for Given name for the PostType. You can make multiple post type just change Carrer Name.
// career CUSTOM POST
$labels = array(
'name' => 'career',
'singular_name' => 'career',
'add_new' => 'Add career',
'add_new_item' => 'Add New career',
'edit_item' => 'Edit career',
'new_item' => 'New career',
'all_items' => 'All career',
'view_item' => 'View career',
'search_items' => 'Search career',
'not_found' => 'No career found',
'not_found_in_trash' => 'No career found in Trash',
'parent_item_colon' => '',
'menu_name' => 'career'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'taxonomies' => array('career_cat'),
'supports' => array(
'title',
'editor',
'excerpt',
'thumbnail',
'custom-fields'
)
);
register_post_type('career', $args);
$labels = array(
'name' => 'career_Category',
'singular_name' => 'career',
'search_items' => 'Search career_Categories',
'all_items' => 'All career_Categories',
'parent_item' => 'Parent career_Category',
'parent_item_colon' => 'Parent career_Category:',
'edit_item' => 'Edit career_Category',
'update_item' => 'Update career_Category',
'add_new_item' => 'Add New career_Category',
'new_item_name' => 'New Category Name',
'menu_name' => 'career_Categories'
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'rewrite' => false,
'capabilities' => array('manage_terms')
);
register_taxonomy('career_cat', array('career'), $args);
add_theme_support('post-thumbnails', array('career'));
set_post_thumbnail_size(100, 100);
"Portfolio" name Used for the PostType. You can Add portfolio-category remove and also add tags.
function ag_custom_post_type_init() {
$ag_cust_post_argu = '';
$ag_cust_post_argu = array(
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'query_var' => true,
'has_archive' => true,
'hierarchical' => true,
'menu_position' => null,
'menu_icon' => null,
'supports' => array( 'title', 'editor' )
);
register_post_type(
'portfolio', array(
'labels' => array('name' => __( 'Portfolio' ), 'singular_name' => __( 'portfolio' ) ),
'hierarchical' => true,
'public' => true,
'rewrite' => array(
'slug' => 'portfolio',
'with_front' => false,
),
'menu_icon' => 'dashicons-admin-site',
'has_archive' => true,
'parent' => 'Portfolio',
'supports' => array('page-attributes','title', 'editor', 'thumbnail', 'comments', 'excerpt'),
$ag_cust_post_argu,
)
);
}
add_action( 'init', 'ag_custom_post_type_init' );
function custom_post_type_tax_init_portfolio() {
register_taxonomy(
'portfolio-category',
'portfolio',
array(
'label' => __( 'Categories' ),
'hierarchical' => true,
'rewrite' => array(
'slug' => 'portfolio-category',
'with_front' => false,
),
)
);
}
add_action( 'init', 'custom_post_type_tax_init_portfolio' );
function custom_post_type_tag_init_portfolio() {
register_taxonomy('portfolio_tag', 'portfolio', array(
'hierarchical' => false,
'label' => "Tags",
'singular_name' => "tag",
'rewrite' => array(
'slug' => 'portfolio-tag',
'with_front' => false,
),
'query_var' => true
)
);
}
add_action( 'init', 'custom_post_type_tag_init_portfolio' );

Resources