• I created a CPT which allows the user to add people to the page. I have already created a page template for displaying all people (page-cpt-people.php). This page also displays all categories used for people. My problem: How do I achieve that when the user clicks on a category only people who have this category are displayed?

    For displaying all categories on my page-cpt-people.php I use this code:

    <?php
    
            $taxonomy = 'people_categories';
            $terms = get_terms($taxonomy); // Get all terms of a taxonomy
    
            if ( $terms && !is_wp_error( $terms ) ) :
            ?>
                <ul>
                    <?php foreach ( $terms as $term ) { ?>
                        <li><a href="<?php echo get_term_link($term->slug, $taxonomy); ?>"><?php echo $term->name; ?></a></li>
                    <?php } ?>
                </ul>
            <?php endif;?>
    
            ?>

    Displaying the categories works perfectly.

    My problems:

    – I don’t know what name to give to my taxonomy file so that the user gets directed to it after clicking on one category.

    – What code do I need to include into this taxonomy file so that only those people are displayed who have the category selected?

    – What changes I maybe need to make to my code above so that everything works?

    Any help is appreciated! ??

  • The topic ‘Linking from CPT to taxonomy-file’ is closed to new replies.