Taxonomy link not working (leads to 404 page)


I’ve created a website where I use Taxonomies for adding an extra category future. This feature works in the backend (admin) and is showing up correctly under the article. The problem is that the link doesn’t work. If I click on the Taxonomy-link, it sends me to a 404 page.

This is the article:

You must click on ‘Videoblogs’ next to ‘Soort blog’ to see the problem. So what I want is to have an archive/collection page of all the posts what have the same taxonomy when you click on the taxonomy.

This is the code I added in the functions.php:

add_action( 'init', 'create_soortpost_taxonomy' );

function create_soortpost_taxonomy() {
        'label' => 'Soort Post',
        'hierarchical' => true,
        'public' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => true,
        'query_var' => true

And the code for showing the output of the Taxonomy link in single.php is:

                    $terms = get_the_terms( $post->link , 'soortpost' );
                    $term_link = get_term_link( $term );
                    // Loop over each item since it's an array
                     if ( $terms != null ){
                     foreach( $terms as $term ) {

                     // Print the name method from $term which is an OBJECT

             echo '<a href="'.get_term_link($term->slug, 'soortpost').'">'.$term->name.'</a>'; 

 // Get rid of the other data stored in the object, since it's not needed
      } } ?>
, , Dave Schepers 10 months 0 Answers 85 views 0

Leave an answer