• 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 Template with Single Category List

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 › General Discussion › Custom Template with Single Category List

This topic is: resolved

Tagged: category template, page template

  • This topic has 4 replies, 2 voices, and was last updated 11 years, 3 months ago by Brad West.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • August 19, 2014 at 2:30 am #119719
    Brad West
    Member

    I'd like to create a page template where the content of the page is displayed and below that a single category archive listing.

    I've looked high and low but can't find any tutorial or code that will produce what I'm looking for; any advice?

    August 19, 2014 at 2:38 am #119720
    Brad Dalton
    Participant

    Wrote about this recently however you could simply use the categories widget or Genesis Featured Posts widget in the after entry widget area.


    Tutorials for StudioPress Themes.

    August 19, 2014 at 2:55 am #119722
    Brad West
    Member

    I can't get that code to work. It says it must run inside the loop so here's how I've added to my template file:

    
    <?php
    //* Template Name: Language Learning Archive
    
    add_action( 'genesis_entry_content', 'genesis_page_archive_content' );
    add_action( 'genesis_post_content', 'genesis_page_archive_content' );
    
    /** Replace the standard loop with our custom loop */
    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'custom-archive' );
      
    function custom-archive() { 
    	
    $args = array(
    	'category_name' => 'language-learning', 
    );
    $wpsites_catposts = new WP_Query( $args ); 
     
    // Your Custom Loop
        if ( $wpsites_catposts->have_posts() ) {
     
            echo '<div class="list-category"><ul>';
    		
    	while ( $wpsites_catposts->have_posts() ) {
    	
    		$wpsites_catposts->the_post();
    		
    		echo '<li><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . get_the_title() . '</a></li>';
    	}
            echo '</ul></div>';
    } else {
    	  echo '<div class="list-category">No posts found for this query.</div>';
    }
    
    wp_reset_postdata();
    	
    }
         
    genesis();
    

    And as for the After Entry Widget, that will add the categories to all pages, no?

    August 19, 2014 at 3:15 am #119723
    Brad Dalton
    Participant

    Please ask any questions relating to this code in the comments where you got the code.


    Tutorials for StudioPress Themes.

    August 19, 2014 at 10:22 pm #119933
    Brad West
    Member

    I was finally able to get it working. For others who might be looking this was my solution:

    
    <?php
    //* Template Name: TEMPLATE NAME
    
    add_action( 'genesis_entry_content', 'genesis_page_archive_content' );
    add_action( 'genesis_post_content', 'genesis_page_archive_content' );
    
    function genesis_page_archive_content() {
    
    	query_posts( array ( 'category_name' => 'CATEGORY-NAME', 'posts_per_page' => -1 ) ); ?>
    	
    	<ul>
    		<div class="custom-archives"><?php
    		
    		while ( have_posts() ) : the_post();
    			echo '<li>';
    			echo '<a href="' . get_permalink() . '">' . get_the_title() . '</a>';
    			echo '</li>';
    		endwhile;
    		
    		?></div>
    	</ul>
    
    <?php
    	wp_reset_query();
    }
    
    genesis();
    
  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Custom Template with Single Category List’ is closed to new 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