WordPress.org

Ready to get started?Download WordPress

Forums

Display Terms In Order of Most Recent Post (1 post)

  1. Josh Byers
    Member
    Posted 4 years ago #

    I am trying to display a list of terms registered to a custom post type but I want the terms ordered by the most recent post. (The terms are a custom taxonomy)

    My specific example is this:
    Users are uploading podcasts which will be categorized by a series name. Each podcast will only have one series name.

    I want to display all the series titles in order of whatever is the most current. You can see this page for an example. So the series that has the latest podcast shows up first in the list.

    This is the code that is currently generating what you see in the example page.

    <div class="latest_series">
    <h2>Recent Series</h2>
    <?php $results = get_terms('series-name', 'order=desc&orderby=id&number=3');
    if ($results) {
    foreach ($results as $result) {
    $img = $taxonomy_images_plugin->get_image_html( 'Sermon Series Medium', $result->term_taxonomy_id );
    $siteurl = get_bloginfo('url');
    if( !empty( $img ) )
    print '' . $img . '';
    echo ' <h3>slug.'">'.$result->name.'</h3>';
    query_posts( array( 'series-name' => $result->slug, 'showposts' => 1, 'order' => 'ASC', ) );
    if (have_posts()) : while (have_posts()) : the_post();
    the_time('M jS, Y');
    endwhile; endif;
    echo '—';
    query_posts( array( 'series-name' => $result->slug, 'showposts' => 1, 'order' => 'DSC', ) );
    if (have_posts()) : while (have_posts()) : the_post();
    the_time('M jS, Y');
    endwhile; endif;
    echo '<p>'.$result->description.'</p>';
    echo '<div class="hr"></hr></div>';
    }
    }
    ?>
    </div><!-- end .latest_series -->

Topic Closed

This topic has been closed to new replies.

About this Topic