Sorting in Archives

Community Forums Forums General Discussion Sorting in Archives

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  Tom 7 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #106046

    dhrose
    Participant
    Post count: 11

    I’m creating a listing of videos as posts. I’ve created categories for the videos, but I want to be able to sort the “posts” / videos by name or category… not by post date in the archives. Is there a way to do that? Also I’ve created categories for videos, training and documents. The subcategories for those contain “categories” that are the same for video, training and documents. Is there a way to not repeat the subcategories other than renaming them. i.e. v-health and safety, d-health and safety etc. ???

    #106102

    Tom
    Participant
    Post count: 1038

    For sorting your posts categorized with ‘video’, use the following to sort by title:

    add_action( 'pre_get_posts', 'kp_reverse_post_order' );
    
    function kp_reverse_post_order( $query ) {
        if ( is_admin() )
            return;
    
        // Only change the query for video post archives.
        if ( $query->is_main_query('video') && is_archive('video') && ! is_post_type_archive('video') ) {
            $query->set( 'orderby', 'title' );
            $query->set( 'order', 'ASC' );
        }
    }

    Reference: Robert Neu : Reverse the Post Order on the Genesis Framework
    Reference: Kevin Shoffner : Genesis Custom Category Pages

    Sorting by category is more problematic: which category will you sort by? I assume that you mean to generate order from other categories like “health”, “safety”, “OSHA”?

    For your question of not repeating other categories, you might consider using only “video” as a post category and tags for the sub classification. You would only need to maintain one tag usable against all categories, video, training, document, etc.


    Choose your next site design from over 350 Genesis themes.
    Updates via GenesisThemes.ca | Twitter | Google+ | Tumblr

    #106239

    dhrose
    Participant
    Post count: 11

    Thanks Tom, I got that working… What I’m trying to do is this: I have a parent category named video. Within that is, hazards, confined space, excavation, safety etc. So From the page: videos, I’m showing the sidebar widget with subcategory: video. Which lists all those subcategories and the (amount) of each category posts. If you click on one of those subcategories it takes you to an archive page listing all the posts in that subcategory (excavation). If I click on the first excavation post, it takes me to the page with that video. What I’d like to do, is on that post page (excavation video) the sidebar shows just “excavation” videos, excavation documents, and excavation training courses. Currently it just shows the default sidebar with “All” videos, “All training Courses,” and “All documents.” So all the videos, training courses, and documents are posts… and categorized. It’s just how to get them (sorted) and on the right sidebar widget… I’ve tried widget logic and creating custom sidebars for everything but it’s getting too confusing. Haven’t tried tags yet. Not sure If I can get it to work without code.

    Thanks!

    #106260

    Tom
    Participant
    Post count: 1038

    This could probably be done with a couple of plugins, depending…

    Since the ‘subcategories’ apply to multiple categories, why not use tags or another, common taxonomy? I don’t know of any case where subcategories can have multiple parent categories. Why do you need a hierarchy?

    How many categories will be treated like this? (just videos? videos, documents, courses? more?)
    How many ‘sub-categories’ are there for the “video” category?
    How many posts are there, roughly for a category? for a ‘sub-category’?
    Are you using tags in any way, or other taxonomies for the posts?


    Choose your next site design from over 350 Genesis themes.
    Updates via GenesisThemes.ca | Twitter | Google+ | Tumblr

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.