最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

taxonomy - Custom Taxonomies Archive Page 404

programmeradmin2浏览0评论

I used the "Custom Post Types UI" and "Custom Fields" plug-ins to set up my structure.

I have a custom post type called "artwork". This works fine. Posts have URLs like domain/artwork/title-of-some-random-artwork. When I enter domain/artwork, I get an archive page with all posts of the post type "artwork". That's how it should be.

Within the "Artwork" post type, I have taxonomies for "Artist", "Movie" and "Company" (connected to custom fields which can be filled in when I entered a new movie, a new artist or a new company). When I enter domain/artists/name-of-an-artist, I get an archive page with all the artwork from that artist. But when I only enter domain/artists, I get a 404 error. Instead, I would like to get a page with a list of all artist entries from the "artists" taxonomy.

Same problem with the "Movie" taxonomy: When I enter domain/movies/some-movie-title, I get an archive page with all the artworks from that movie. Again, everything fine. But when I only enter domain/movies, I get a 404 error. Instead, I would like to get a list of all movie title entries from the "movies" taxonomy.

I googled for hours, but couldn't find a solution.

Thank you for your help!

I used the "Custom Post Types UI" and "Custom Fields" plug-ins to set up my structure.

I have a custom post type called "artwork". This works fine. Posts have URLs like domain/artwork/title-of-some-random-artwork. When I enter domain/artwork, I get an archive page with all posts of the post type "artwork". That's how it should be.

Within the "Artwork" post type, I have taxonomies for "Artist", "Movie" and "Company" (connected to custom fields which can be filled in when I entered a new movie, a new artist or a new company). When I enter domain/artists/name-of-an-artist, I get an archive page with all the artwork from that artist. But when I only enter domain/artists, I get a 404 error. Instead, I would like to get a page with a list of all artist entries from the "artists" taxonomy.

Same problem with the "Movie" taxonomy: When I enter domain/movies/some-movie-title, I get an archive page with all the artworks from that movie. Again, everything fine. But when I only enter domain/movies, I get a 404 error. Instead, I would like to get a list of all movie title entries from the "movies" taxonomy.

I googled for hours, but couldn't find a solution.

Thank you for your help!

Share Improve this question edited Apr 6, 2020 at 5:48 HAL2020 asked Apr 6, 2020 at 5:37 HAL2020HAL2020 398 bronze badges 3
  • You need to activate archive option on Custom Post UI on you custom post – TodoViernes Commented Apr 6, 2020 at 6:46
  • Yes, I already activated this. It works with the custom posts, as described in the original post. But there is no such option when you create a new taxonomy in Custom Post UI (the option is only there when you create a new custom post type). – HAL2020 Commented Apr 6, 2020 at 7:13
  • Unfortunately, taxonomies by default do not have any archives which lists posts in any terms in the taxonomy. You'll need to use custom SQL for that, and possibly with custom URL rewriting. Or you can create a Page (e.g. with the slug artists) and run a custom WP_Query loop in the Page template. – Sally CJ Commented Apr 6, 2020 at 14:27
Add a comment  | 

1 Answer 1

Reset to default 0

I solved it with this workaround. I created a new page ("Movies" with the URL domain/movies) and added this via shortcode:

<?php
     $taxonomy = 'artists';
     $tax_terms = get_terms( $taxonomy, array(
    'post_type' => 'artwork',
    'orderby' => 'name',
    'order' => 'ASC' 
     ) );
 ?>
 <?php
     foreach ($tax_terms as $tax_term) {
 ?><div class="artistslist">
     <a href="/<?php echo $taxonomy;?>/<?php echo $tax_term->slug;?>"><?php echo $tax_term->name;?>
     </div>
 <?php } ?>

Now I can access artist archives via domain/artists/some-artist-name, and an A-Z list of all artists on domain/artists

发布评论

评论列表(0)

  1. 暂无评论