Forum Replies Created
-
AuthorPosts
-
BeneathsMember
Ended up brain storming a different way to just push the layout to the client and I'd update him when I figured out a cleaner version.
Parent Category issue:
Decided I'd make category specific ID pages so, category-22.php etc in which would have the following code:
(This would allow for only the main category pages to list off the subcategories)<?php remove_action( 'genesis_loop', 'genesis_do_loop' ); add_action( 'genesis_loop', 'sk_show_subcategories_do_loop' ); /** * Displays a list of linked child categories on category pages */ function sk_show_subcategories_do_loop() { $cat = get_query_var('cat'); $category = get_category ($cat); if ($category->cat_ID) { $children = wp_list_categories("orderby=id&depth=0&hide_empty=0&title_li=&child_of=".$category->cat_ID."&echo=0"); // change depth to 1 if only the top level sub categories should be shown i.e., with children NOT expanded if ($children) { echo $children; } } } genesis();
Subcategory issue:
And to solve the subcategories only listing off the posts in the titles only, I used the following code:
(Subcategories would only display post's titles)add_action( 'pre_get_posts', 'sk_show_titles_only_category_pages' ); /** * Show Linked Titles Only for Posts in Category Pages */ function sk_show_titles_only_category_pages( $query ) { if( $query->is_main_query() && $query->is_category() ) { $query->set( 'orderby', 'title' ); $query->set( 'order', 'ASC' ); // $query->set( 'posts_per_page', '2' ); //* Remove the post info remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); //* Remove the post thumbnail remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); //* Remove the post content remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); remove_action( 'genesis_entry_content', 'genesis_do_post_content_nav', 12 ); remove_action( 'genesis_entry_content', 'genesis_do_post_permalink', 14 ); //* Remove the post meta remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 ); remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 ); remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); remove_action( 'genesis_loop', 'genesis_do_loop' ); add_action( 'genesis_loop', 'sk_custom_loop' ); } } function sk_custom_loop() { //* Use old loop hook structure if not supporting HTML5 if ( ! genesis_html5() ) { genesis_legacy_loop(); return; } if ( have_posts() ) : while ( have_posts() ) : the_post(); do_action( 'genesis_before_entry' ); printf( '<article %s>', genesis_attr( 'entry' ) ); do_action( 'genesis_entry_header' ); do_action( 'genesis_before_entry_content' ); // printf( '<div %s>', genesis_attr( 'entry-content' ) ); do_action( 'genesis_entry_content' ); // echo '</div>'; //* end .entry-content do_action( 'genesis_after_entry_content' ); do_action( 'genesis_entry_footer' ); echo '</article>'; do_action( 'genesis_after_entry' ); endwhile; //* end of one post do_action( 'genesis_after_endwhile' ); else : //* if no posts exist do_action( 'genesis_loop_else' ); endif; //* end loop }
Next step: Try to use conditional tags to display the codes instead of having to have so many custom category id pages. Essentially, just a cleaner layout.
April 18, 2014 at 4:03 pm in reply to: News Pro: How to Exclude Child Category Posts from Parent Category Archive #101222BeneathsMemberDid you ever make any headway on this? I've been searching the last few days and it doesn't seem I'm alone trying to figure it out. Most articles too are simply outdated
-
AuthorPosts