WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Select Top Post from Post Type Taxonomies (3 posts)

  1. wilhud
    Member
    Posted 3 years ago #

    I'm trying to do the following...

    I have multiple collections (cars, scooters, bicycles, etc.) that I want to setup on my site. Once setup, I want to have a page that lists these collection types with a sample image of one scooter, one bicycle and so on. Ideally it would be the last item added for each collection type. When clicked, the user will be taken to the complete list of items in that collection type.

    My first instinct was to create the Post_type called collections. I did so and then added a taxonomy called type in which I added cars, scooters and such. This works great and I can easily pull the lists for each collection type. However, I'm wondering how do I generate the main collections page where it shows one example of each type?

    I tried the following...

    $loop = new WP_Query( array( 'post_type' => 'collection', 'taxonomy' => 'type', 'posts_per_page' => 10 ) );

    But that was just a shot in the dark and didn't return any results.

    Any assistance is greatly appreciated.

    Thanks,
    Wil

  2. vtxyzzy
    Member
    Posted 3 years ago #

    There are a couple of options shown on this page.

  3. wilhud
    Member
    Posted 3 years ago #

    Thanks vtxyzzy, I had actually ended up coding something similar to the Show 1 Post/Category option that you linked. It seems to work pretty well. Glad I checked your link though because I had forgotten the 'post_status' => 'publish' part.

    Thanks!
    Wil

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.