• I am currently trying to put together an index of all posts sorted alphabetically by my custom taxonomy ‘rating’. My code has been applied to a custom page template with some success. Here is an abbreviated version of my code (since the content of all the columns isn’t particularly important here):

    <h1>Fantasy</h1>
      <table>
       <?php /////////////// Fantasy ///////////////
          $args = array( 'numberposts' => 100, 'order'=> 'ASC', 'orderby' => 'title', 'genre' => 'fantasy' );
          $myposts = get_posts( $args );
          foreach($myposts as $post) :
          setup_postdata($post);
          ?>
       <tr>
          <td><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></td>
          <td><?php if(get_post_meta($post->ID, 'Author', true)) {
             echo get_post_meta($post->ID, 'Author', true);
             } ?></td>
       </tr>
       <?php endforeach; wp_reset_postdata(); // END FANTASY // ?>
      </table>

    I have two issues with this:

    1. I have 20+ total genres. This means I have to copy-paste the code a lot, which makes for a clunky, messy template. I can’t think of a better way to do this, though, since some posts are assigned more than one category. If I called up all posts at once and added a ‘genre’ column, each title would only appear once with multiple genres listed beside it rather than multiple times, with a single genre listed each time. Is there a way to solve this that I haven’t thought of, or do I need to continue using my inelegant workaround?
    2. Right now I have sorted my table alphabetically by ‘title’, which works alright for the most part. My issue is that I would rather sort my list alphabetically by my custom taxonomy ‘rating’ (which doesn’t appear in the code above as I haven’t added it to my table yet, sorry!) and thereunder alphabetical by title. I can’t seem to find any examples of people doing something like this. Is it possible?

    Thank you for your help in advance!

Viewing 2 replies - 31 through 32 (of 32 total)
  • Thread Starter Rose

    (@eos-rose)

    That gave me the complete list of all genres with counts that seem to match up, yes.

    Then some other plugin or filter must be interfering with the query that retrieves the posts.

    Unfortunately, I can’t offer any suggestions on how to track it down – Sorry.

Viewing 2 replies - 31 through 32 (of 32 total)
  • The topic ‘Creating an index of all posts sorted alphabetically by custom taxonomy’ is closed to new replies.