• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WriteNowDesign - Wordpress and Ecommerce Website Design

WordPress, Joomla, Ecommerce Website Design

  • Home
  • Prices/Packages
  • WordPress
  • Services
  • Portfolio
  • Blog
  • About
    • Testimonials
    • Locations
    • Online Payment
  • Contact
  • Show Search
Hide Search

Call 303-907-6133 Email

genesis custom category template

Create a Category Template in WordPress Genesis

April 1, 2014 by Pat Fortino

Create a Page Template

  1. Create a new page in your theme’s directory called page-articles.php; for example,
    /wp-content/themes/my-genesis-theme/page-articles.php
  2. Paste the following code into page-articles.php:
    <?php
    /* Template Name: Articles Template */
    /** Replace the standard loop with our custom loop */
    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'wnd_do_custom_loop' );
     
    function wnd_do_custom_loop() { 
        global $paged; // current paginated page
        global $query_args; // grab the current wp_query() args
        $args = array(
            'cat' => 8, /* shows all posts and child posts from category id */
            'paged'            => $paged, // respect pagination
        );
    /* If you want to show posts from a category only and no subcategory posts, use 'category_name' => 'category-slug', instead of 'cat' => 8, for example, 'category_name' => 'articles', */
        genesis_custom_loop( wp_parse_args($query_args, $args) );
    }
        
    genesis();
  3. Change the number in ‘cat’ => 8 to the number of the category you want to use.
    Note: To find the category number, go to Posts > Categories and click the category link. In your browser url field, you will see a URL that looks like the following:
    /wp-admin/edit-tags.php?action=edit&taxonomy=category&tag_ID=33&post_type=post
    In the example above, the category number is 33.
  4. If you want, you can change the template name. In the example, modify this line:
    /* Template Name: Articles Template */.
    Articles Template is the template name. This is NOT related to the name we gave the php file.
  5. Save the file.
    Pages: Page 1 Page 2 Page 3

Filed Under: Genesis, Wordpress How To Leave a Comment

Previous Post: « Genesis: How to Modify the Site Description
Next Post: Add Retina Logo to a Genesis Template »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related

Primary Sidebar

Blog Categories

Call Today

Get a Free Quote

303-907-6133

Subscribe to News

News about WordPress, WooCommerce, & Technology

What’s New

  • WPForms Not Sending Notifications
  • Add Terms and Conditions WooCommerce
  • Fix WordPress AMP Validation Errors
  • Use the Classic Editor with Gutenberg Block Editor
  • Add a Message at Top or Bottom of WooCommerce Checkout Page
  • How to Link to a PDF in WordPress

Find Us On…

  • Facebook
  • LinkedIn
  • RSS

Call 303-907-6133 Email

© 2004–2023 · WriteNowDesign · Sitemap · Log in · Return to Top