• 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 comments.php

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 comments.php

This topic is: not resolved

Tagged: child theme, comments.php

  • This topic has 3 replies, 2 voices, and was last updated 4 years, 7 months ago by Victor Font.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • July 28, 2018 at 10:49 pm #222076
    jeremyers1
    Member

    I see that there are various comments.php files in the Genesis framework ... one in the Genesis root directory (..themes/genesis/comments.php) and another in the lib/structure directory (..themes/genesis/lib/structure/comments.php). It is the second that seems to govern the layout of the comments area.

    So is it possible to add a custom comments.php file which overrides the comments.php file inside the lib/structure/ directory? If so, do I just copy that file over to my child theme root directory, or where should I put it so that I can customize it?


    Blogger and Author

    July 29, 2018 at 2:19 am #222079
    Victor Font
    Moderator

    I don't think so. The Genesis init process is designed to load core functions from the Genesis directory structure, not the child theme.

    In its purest sense, the Genesis Framework is an abstraction layer for WordPress functions. It provides structure through its many WordPress hooks. Hooks are actions and filters.

    When you say you want to customize the comments area, doing it the Genesis way generally means either altering the priorities of the hooks or changing what each hook does through your own custom functions. For example, here's a snippet that moves the comments below the comment form. It's a major structural change accomplished with a few lines of code:

    add_action( 'genesis_before_comments' , 'move_comments_below_form' );
    function move_comments_below_form()
    {
        if ( is_single() && have_comments() ) {
    
            remove_action( 'genesis_comment_form', 'genesis_do_comment_form' );
            add_action( 'genesis_comments', 'genesis_do_comment_form', 5 );
        }
    }

    If you can be more specific about what you want to accomplish, maybe someone can point you to the right hooks to achieve the result.


    Regards,

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

    July 29, 2018 at 11:02 pm #222097
    jeremyers1
    Member

    Thanks.

    I want to be able to add some details about the author beneath their author gravatar. Specifically, I am using the GamiPress plugin, and want to add the comment authors GamiPress level beneath their avatar image. (Almost exactly as done here on this forum, except instead of "Participant" or "Moderator" I want the GamiPress achievements to show.)

    I wrote a bit about it here, but no one replied.

    https://www.studiopress.community/topic/add-gamipress-details-below-avatar-in-comment-section/


    Blogger and Author

    July 30, 2018 at 9:21 am #222113
    Victor Font
    Moderator

    What you want to do is a little tricky because there aren't any filters in the genesis_html5_comment_callback that will allow you to modify the author area. This means you have to create a couple of custom functions. The first changes the comment defaults to use your second function that replaces genesis_html5_comment_callback.

    None of this is tested, but it will give you an idea of what's involved.

    add_filter( 'genesis_comment_list_args', 'change_comment_defaults' );
    function change_comment_defaults( $defaults ){
    
        $defaults = array(
    		'type'        => 'comment',
    		'avatar_size' => 48,
    		'format'      => 'html5', // Not necessary, but a good example.
    		'callback'    => genesis_html5() ? 'my_custom_html5_comment_callback' : 'genesis_comment_callback',
    	);
    
        return $defaults;
    }

    Next, copy the genesis_html5_comment_callback function from lib/structure/comments.php into functions.php. Rename it to my_custom_html5_comment_callback, then modify it as you desire.

    Don't make these modifications through the WordPress editor. It's too easy to bring your site down.

    Make a backup of your site. Use FTP and a local editor to make the changes.

    Good luck with this.


    Regards,

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

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 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

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