I'm going crazy...
I've have spend all day trying to achive this.
All tutorials and forums I read says the same. But it doesnt work for me!
I have created a custom post type, with custom taxonomy.
Everything is showing fine.
But when I click on taxonomy-link, nothing is showing - Only a standard message: "It seems we can’t find what you’re looking for".
How do I get a page, for items that has the same taxonomy to show?
..
When I read around:
"take your archive.php, copy, rename it taxonomy-taxonomy-slug.php and upload to child theme."
So I have created a taxonomy called Locations. Here I have New York.
Now I want all the post whit "New York" to show:
So in order to get this to work, I take archive.php and rename it - taxonomy-locations-new-york.php.
But it doesn't work!
Is that right? Or do I need to add a certain code?
This is the code for the custom post and taxonomy:
<?php
/************* The Post ***********************/
function register_job_post_type(){
$singular = 'Job';
$plural = 'Jobs';
$labels = array (
'name' => $singular,
'singular_name' => $singular,
'add_name' => 'Add New',
'add_new_item' => 'Add New ' . $singular,
'edit' => 'Edit',
'edit_item' => 'Edit ' . $singular,
'new_item' => 'New' . $singular,
'view_item' => 'View ' . $singular,
'search_term' => 'Search ' . $plural,
'parent' => 'Parent ' . $singular,
'not_found' => 'No ' . $plural . ' found',
'not_found_in_trash' => 'No ' . $plural . ' in Trash'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'exclude_from_search' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_admin_bar' => true,
'menu_position' => 6,
'menu_icon' => 'dashicons-admin-site',
'can_export' => true,
'delete_with_user' => false,
'hierarchical' => true,
'has_archive' => true,
'query_var' => true,
'capability_type' => 'post',
'map_meta_cap' => true,
// 'capabilities => array(),'
'rewrite' => array(
'slug' => 'cpt',
'with_front' => true,
'pages' => true,
'feeds' => true,
),
'supports' => array(
'title',
'editor',
'author',
'custom-fields',
'thumbnail'
)
);
register_post_type( 'cpt', $args);
}
add_action( 'init', 'register_job_post_type' );
/****************** Taxonomy ***********************************/
function register_job_taxonomy(){
$plural = 'locations';
$singular = 'location';
$labels = array(
'name' => $singular,
'singular_name' => $singular,
'search_items' => 'Search ' . $plural,
'popular_items' => 'Popular ' . $plural,
'all_items' => 'All ' . $plural,
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => 'Edit ' . $singular,
'update_item' => 'update ' . $singular,
'add_new_item' => 'Add New ' . $singular,
'new_item_name' => 'New ' . $singular . ' Name',
'separate_items_with_commas' => 'Separate ' . $singular . ' with commas',
'add_or_remove_items' => 'Add or remove ' . $plural,
'choose_from_most_used' => 'Choose from most used ' . $plural,
'not_found' => 'No ' . $plural . ' found.',
);
$args = array (
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'location' ),
);
register_taxonomy( 'locations', 'cpt', $args);
}
add_action ( 'init', 'register_job_taxonomy' );