CommentPress Core
[resolved] modify a commentpress template (5 posts)

  1. carlsandburg
    Posted 1 year ago #

    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?



  2. Christian Wach
    Plugin Author

    Posted 1 year ago #

    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

  3. carlsandburg
    Posted 1 year ago #

    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?

  4. carlsandburg
    Posted 1 year ago #

    NEVERMIND! figured it out. It goes in function.php. I'm going to get this all figured out one day :-)


  5. carlsandburg
    Posted 1 year ago #

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


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • CommentPress Core
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.