0

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

3
  • 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? Jun 27, 2019 at 10:02
  • @JacobPeattie I edited it
    – Dario B.
    Jun 27, 2019 at 10:34

1 Answer 1

1

The 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.

3
  • That's what I thought, but I created it again to boar, it does not work. I receive a 404 error
    – Dario B.
    Jun 27, 2019 at 10:51
  • Ok, then the issue has nothing to do with templates. You should have specified that you got a 404 error. Even if you're missing the correct template you wouldn't get a 404. It sounds like you just need to flush permalinks. Jun 27, 2019 at 10:59
  • OH!!! this really work. Thanks you very much!!
    – Dario B.
    Jun 27, 2019 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.