• 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

Add div class to custom category template

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 › Add div class to custom category template

This topic is: not resolved
  • This topic has 5 replies, 2 voices, and was last updated 9 years, 5 months ago by babrees.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • January 29, 2017 at 1:37 am #200210
    babrees
    Participant

    I have a custom template for just one category.
    Can I add a div to wrap each entry?

    January 29, 2017 at 7:02 am #200214
    Victor Font
    Moderator

    You can probably hook into genesis_before_entry and genesis_after_entry with something like this:

    add_action('genesis_before_entry','add_custom_div_open');
    add_action('genesis_after_entry','add_custom_div_close');
    
    function add_custom_div_open() {
        if ( is_category() ) {
            echo '<div class="my-custom-class">';
        }
    }
    
    function add_custom_div_close() {
        if ( is_category() ) {
            echo '</div>';
        }
    

    }


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    January 29, 2017 at 7:54 am #200217
    babrees
    Participant

    Thanks Victor, but that that didn't work. Didn't make any difference at all.

    I neglected to say I'm using Altitude theme, don't expect that would make a difference though.

    January 29, 2017 at 12:03 pm #200224
    Victor Font
    Moderator

    I tested the code with Altitude Pro in my local environment and it works fine. How are you creating the category page? The is_category conditional works with category pages created from the menu. If you are creating a category page in some other fashion, you may have to use a different conditional. There's no way to tell without a link to your site.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    January 29, 2017 at 3:36 pm #200231
    babrees
    Participant

    Yes, I created the category from the menu, but I do have a category template...

    <?php
    
    //* Remove the post title function
    remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
    
    //* Add the post title function
    add_action( 'genesis_entry_content', 'genesis_do_post_title', 11 );
    
    //* Remove the post info function
    remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
    
    //* Remove the post content
    remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
    
    //* Remove the post meta function
    remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
    
    genesis();
    

    This is the exact code I put into functions.php...

    //* add new class div to wrap entry in photo gallery
    add_action('genesis_before_entry','add_custom_div_open');
    add_action('genesis_after_entry','add_custom_div_close');
    
    function add_custom_div_open() {
        if ( is_category( 'photo-gallery' ) ) {
            echo '<div class="photo-gallery-class">';
        }
    }
    
    function add_custom_div_close() {
        if ( is_category( 'photo-gallery' ) ) {
            echo '</div>';
        }
    }
    January 30, 2017 at 4:31 am #200240
    babrees
    Participant

    Hi Victor - got it working!!!! My fault entirely. I had tried so many different things and I had inadvertently not deleted one bit I had tried previously and that was the problem!

    I'd like to say thank you for all your help in this forum. Words can not say how much it is appreciated!

    Thanks

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘General Discussion’ 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

© 2026 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