• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Custom Category Pages

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Custom Category Pages

This topic is: not resolved

Tagged: category, custom category

  • This topic has 2 replies, 2 voices, and was last updated 11 years, 6 months ago by Beneaths.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • April 17, 2014 at 7:04 pm #101082
    Beneaths
    Member

    I've spent a good quality of time trying to find a answer for this and I'm sure if I kept putting more time into it, I could manage to figure it out but I'd love a little help.

    I decided I needed a custom category page for my clients website. Currently it is set up where they want the following:
    domain/Category1/Category1.2/Post

    Category1: Must list out all categories such as Category1.1, Category1.2 etc

    Category1.1 (and so on): Must list out all posts that are in the 1.1 category

    Each category needs a excerpt above the posts/category links in order to post a description about the categories/posts that are linked.

    So far, I decided a custom category.php is needed and I've been struggling since. Any help to point me in the right direction would be great.

    I'm at the point that maybe essentially just making it a post may be better but the automation of having the posts automatically added due to it being a category seems nice in the long run instead of having to keep reediting the categories..

    April 18, 2014 at 5:58 am #101113
    Brad Dalton
    Participant

    Try pre_get_posts with conditional tags


    Tutorials for StudioPress Themes.

    April 19, 2014 at 11:50 am #101302
    Beneaths
    Member

    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.

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble