i have a custom_post_type:
// Referenzen Post type
function create_post_type_referenzen()
{
register_post_type('referenzen', array(
'label' => __('Referenzen'),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_icon' => 'dashicons-welcome-write-blog',
'supports' => array('thumbnail', 'title', 'editor', 'author',
'excerpt', 'comments')
)
);
}
add_action('init', 'create_post_type_referenzen');
with custom:taxonomys:
function tr_create_my_taxonomy()
{
register_taxonomy(
'veranstaltungen-category',
'veranstaltungen',
array(
'label' => __('Category'),
'rewrite' => array('slug' => 'veranstaltungen-category'),
'hierarchical' => true,
)
);
}
add_action('init', 'tr_create_my_taxonomy');
This list of taxonomies can be viewed on the web, you can click on them. My PROBLEM is that I can not find the correct file so that if I click on movies, for example. Only receive on the web the list of events of the cinema taxonomy. I tested with taxonomy.php and with category.php, but the answer is still unsuccessful. Can someone tell me what I'm doing wrong? Thank you
--EDIT--
I have registered custom taxonomies because I have a custom_post_type not activated by default the option to add categories and taxonomies. Then I have added the categories allgemain (general), kino (cinema), and Konzert (concert).
This list of categories I have made visible as follows:
<?php
$taxonomy = 'veranstaltungen-category';
$orderby = 'name';
$show_count = false;
$pad_counts = false;
$hierarchical = true;
$title = '';
$args = array(
'taxonomy' => $taxonomy,
'orderby' => $orderby,
'show_count' => $show_count,
'pad_counts' => $pad_counts,
'hierarchical' => $hierarchical,
'title_li' => $title
);
?>
<ul class="columns is-multiline catList">
<?php wp_list_categories($args); ?>
</ul>
and what I get in response is the following:
<ul class="columns is-multiline catList">
<li class="cat-item cat-item-13"><a href="URL/allgemein/">Allgemein</a>
</li>
<li class="cat-item cat-item-14"><a href="URL/kino/">Kino</a></li>
<li class="cat-item cat-item-12"><a href="URL/konzerte/">Konzerte</a</li>
</ul>
When the visitor clicks on one of the options, he should receive a filtered web with only kino for example. But neither category.php, nor taxonomy.php, nor archive.php, nor category- {slug} .php, nor taxonomy- {slug} .php, nor archive- {slug} .php work (slug = veranstaltungen-category)
Or maybe I've made a mess and I've done it wrong
i have a custom_post_type:
// Referenzen Post type
function create_post_type_referenzen()
{
register_post_type('referenzen', array(
'label' => __('Referenzen'),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_icon' => 'dashicons-welcome-write-blog',
'supports' => array('thumbnail', 'title', 'editor', 'author',
'excerpt', 'comments')
)
);
}
add_action('init', 'create_post_type_referenzen');
with custom:taxonomys:
function tr_create_my_taxonomy()
{
register_taxonomy(
'veranstaltungen-category',
'veranstaltungen',
array(
'label' => __('Category'),
'rewrite' => array('slug' => 'veranstaltungen-category'),
'hierarchical' => true,
)
);
}
add_action('init', 'tr_create_my_taxonomy');
This list of taxonomies can be viewed on the web, you can click on them. My PROBLEM is that I can not find the correct file so that if I click on movies, for example. Only receive on the web the list of events of the cinema taxonomy. I tested with taxonomy.php and with category.php, but the answer is still unsuccessful. Can someone tell me what I'm doing wrong? Thank you
--EDIT--
I have registered custom taxonomies because I have a custom_post_type not activated by default the option to add categories and taxonomies. Then I have added the categories allgemain (general), kino (cinema), and Konzert (concert).
This list of categories I have made visible as follows:
<?php
$taxonomy = 'veranstaltungen-category';
$orderby = 'name';
$show_count = false;
$pad_counts = false;
$hierarchical = true;
$title = '';
$args = array(
'taxonomy' => $taxonomy,
'orderby' => $orderby,
'show_count' => $show_count,
'pad_counts' => $pad_counts,
'hierarchical' => $hierarchical,
'title_li' => $title
);
?>
<ul class="columns is-multiline catList">
<?php wp_list_categories($args); ?>
</ul>
and what I get in response is the following:
<ul class="columns is-multiline catList">
<li class="cat-item cat-item-13"><a href="URL/allgemein/">Allgemein</a>
</li>
<li class="cat-item cat-item-14"><a href="URL/kino/">Kino</a></li>
<li class="cat-item cat-item-12"><a href="URL/konzerte/">Konzerte</a</li>
</ul>
When the visitor clicks on one of the options, he should receive a filtered web with only kino for example. But neither category.php, nor taxonomy.php, nor archive.php, nor category- {slug} .php, nor taxonomy- {slug} .php, nor archive- {slug} .php work (slug = veranstaltungen-category)
Or maybe I've made a mess and I've done it wrong
Share Improve this question edited Jun 27, 2019 at 10:33 Dario B. asked Jun 27, 2019 at 9:51 Dario B.Dario B. 15510 bronze badges 3- Please refer developer.wordpress/themes/template-files-section/… – Pratik Patel Commented Jun 27, 2019 at 9:54
- Your question is confusing because your post type code is for a different post type than the taxonomy code is registering a taxonomy for, plus the examples in your question are neither that post type or the taxonomy. Is Movies a post type? A category? A taxonomy? What is events? – Jacob Peattie Commented Jun 27, 2019 at 10:02
- @JacobPeattie I edited it – Dario B. Commented Jun 27, 2019 at 10:34
1 Answer
Reset to default 1The correct template to use in this case would be taxonomy-veranstaltungen-category.php
, and that template needs to use the main loop.
So, at a bare minimum you should have taxonomy-veranstaltungen-category.php
with the following code:
<?php get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php get_footer(); ?>
That will show you the correct posts from the whichever category you select.