[Plugin: Custom Post Type UI] Linking different content types using taxonomies (2 posts)

  1. jacopo3001
    Posted 6 years ago #

    let's say I have to content type: movies and directors.

    what i would like to do is:
    When I am on the page of a Horror movie(genre), i would like to have a box on the right displaying the top 5 Horror directors.

    I guess i would apply the same taxonomy to both content type.
    is that possible?
    once that is in place, how to make the box displaying related content?

    I don't know wordpress too well, I am more of a Drupal person who is trying to move over, so I may need to be explained some of the inner definitions..
    thank you for the great plugin, seems it's just perfect for what I (and i guess a lot of other people ) need.


  2. MichaelH
    Posted 6 years ago #

    //if is a given taxonomy, then get all terms in that taxonomy and display top 5 (by count) of those terms
    if (is_tax('genre')) {
      $taxonomy = 'genre';
        'orderby' => 'count',
        'order' => 'DESC'
      $terms = get_terms($taxonomy,$args);
      $count = 0;
      foreach ($terms as $term) {
        if ($count <= 5) {
          echo '<p>' . '<a href="' . esc_attr(get_term_link($term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a> has ' . $term->count . ' post(s). </p> ';

Topic Closed

This topic has been closed to new replies.

About this Topic