Community Forums › Forums › Archived Forums › General Discussion › Sorting in Archives
Tagged: archive sort, category
- This topic has 3 replies, 2 voices, and was last updated 9 years, 11 months ago by Tom.
-
AuthorPosts
-
May 20, 2014 at 11:39 am #106046dhroseMember
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. ???
May 20, 2014 at 6:06 pm #106102TomParticipantFor 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 PagesSorting 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.
[ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ]May 21, 2014 at 6:15 pm #106239dhroseMemberThanks 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!
May 21, 2014 at 11:00 pm #106260TomParticipantThis 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.
[ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ] -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.