Taxonomy link not working in WordPress (404)
-
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: http://7ef.8b5.myftpupload.com/test/
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() { register_taxonomy( 'soortpost', 'post', array( '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:
<?php $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 unset($term); } } ?>
The topic ‘Taxonomy link not working in WordPress (404)’ is closed to new replies.