Support » Plugin: CommentPress Core » modify a commentpress template

  • Resolved carlsandburg


    I’ve figured out (more or less) how to change the css of CommentPress. Now I want to start modifying the templates.

    I already created a child theme.

    My “long-term” goal is to modify the Header to include a button that take the user to the Blog, but for now, i want to just add some random text.

    i found the template i want to modify.

    header_body.php – i added one line (“hello there”).

    <div id=”page_title”>
    <div id=”title”><h1>” title=”<?php _e( ‘Home’, ‘commentpress-core’ ); ?>”><?php bloginfo(‘title’); ?></h1></div>
    <div id=”tagline”><?php bloginfo(‘description’); ?></div>
    <div id=”tagline”><?php echo ‘hello there’; ?></div>

    now comes the problem. i’ve tried putting it here


    and here


    but when i go to the page i don’t see “Hello there”

    Maybe I’m missing a step?


Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Christian Wach


    Ah yes, it is a little more complicated than that. CommentPress predates many of the capabilities for child themes to override parent theme templates, so instead there are filters that have to be applied. I plan to update this at some point. Anyway, here’s what you need to do:

     * @description: override header_body template by intercepting value
    function my_header_body_template() {
    	return get_stylesheet_directory() . '/assets/templates/header_body.php';
    add_filter('cp_template_header_body', 'my_header_body_template');

    Hope that helps. Cheers, Christian

    Thanks, that helps. I added that code to my child theme – /wp-content/themes/commentpress-modern-child/header.php (at the bottom).

    This code does seem to get executed.

    However, it seems that header_body is still being executed from /plugins/commentpress-core/themes/comment-press-modern/assets/templates/header_body.php instead of from the same directory in my child theme.

    Maybe there’s something else i need to do as well? It’s probably something basic – I’m still new to this…..

    any thoughts?

    NEVERMIND! figured it out. It goes in function.php. I’m going to get this all figured out one day 🙂


    ok – got a link to the blog on the header now.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘modify a commentpress template’ is closed to new replies.