List specific field of specific taxonomy

Question

I have a custom post type “artwork”. Every “artwork”-post has custom fields that are connected to taxonomies: “Artist” (Who’s the designer), “Movie” (which movie the artwork is for), and “Agency” (the agency who produced the artwork).

In my backend, under “Artwork Posts”, I have: “Movies”, “Artists” and “Agencies”.

I have managed to list all Movies from A-Z on one page, and all artists from A-Z on another page. That’s how I did it:

<?php
     $taxonomy = 'mmovies';
     $tax_terms = get_terms( $taxonomy, array(
        'post_type' => 'artwork',
    'orderby' => 'name',
    'order' => 'ASC' 
     ) );

 ?>  <?php
     foreach ($tax_terms as $tax_term) {
         ?>
     <div class="movieslist">
         <a href="/<?php echo $taxonomy;?>/<?php echo $tax_term->slug;?>"><?php echo $tax_term->name;?>
     </div>  <?php } ?>

That works fine at the moment…

What I need to do now on another subpage:

  1. Display a list with all entries of the “Genre” field from all
    entries of the “movies” taxonomy (every entry in the “movies”
    taxonomy has at least one genre, some have two or three).
  2. Display an archive of posts from the “movies” taxonomy which have a certain “genre”.

Example: In my “movies” taxonomy, I have an entry “Batman”, which has the Genres “Action” and “Adventure” attached. And I have another entry “Friday the 13th” which has the genre “Horror” attached.

One page (e.g. domain.cc/genres), would look like this:
TITLE
Action -> link to domain.cc/genres/action/
Adventure -> link to domain.cc/genres/adventure/
Horror -> link to domain.cc/genres/horror/

A click on “Horror” should lead us to an archive page which lists all entries from the “movies” taxonomy if the genre custom field is “Horror”.

Thank you for your help!

0
, , , , HAL2020 3 years 2020-04-06T04:50:58-05:00 0 Answers 88 views 0

Leave an answer

Browse
Browse