categories - custom page for custom Taxonomy

i have a custom_post_type: Referenzen Post typefunction create_post_type_referenzen(){register_post_type('refer

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
Add a comment  | 

1 Answer 1

Reset to default 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745365569a4624561.html

相关推荐

  • categories - custom page for custom Taxonomy

    i have a custom_post_type: Referenzen Post typefunction create_post_type_referenzen(){register_post_type('refer

    13小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信