• I was stuck on this for a while and just figured it out. Maybe this will help someone else. From the description in the file includes/template-tags.php ” * To override this walker in a child theme without modifying the comments template
    * simply create your own leaf_comment(), and that function will be used instead.” It looked like I should be able to copy includes/template-tags.php into my child theme, modify the leaf_comment function, and change the output of my comments.

    WRONG! the answer is to copy /create the function(s) you want to modify into your otherwise empty functions.php.

    I looked at the recommended leaf child theme, which only discusses removing functions that aren’t in proper wrappers and does not apply here. I tried all sorts of silliness to get the function file in my child’s includes folder to load – giving it a new name so as to not conflict with the parent and so on. In hindsight maybe it should have been obvious to just put naked functions in the child’s functions.php. I feel stupid already. Yea I read all about child themes, but those instructions don’t assume that the parent functions.php is including external files. That threw me.

    If only that comment had said “…simply create your own leaf_comment() in functions.php, and that function will be used instead.”

    I love WordPress, but sometimes the hoops we have to jump through just to change a few lines of text …

Viewing 3 replies - 1 through 3 (of 3 total)
  • webmystery, when you downloaded leaf child theme the functions.php file was the first to watch, you could see that everything is explained.
    As written here and here, in that file you can read that certain functions – those wrapped in a function_exists() call – (the pluggable ones e.g. as leaf_comment), are overwriteable by defining them in your child theme’s functions.php file. The child theme’s functions.php file is included before the parent theme’s file, so the child theme functions is used.
    Take a look also to parent’s theme functions.php, I’m not a coder as you aren’t, but I think it’s because of that definitions (get_template_directory) that the “child theme’s functions thing” works.

    Thread Starter webmystery

    (@webmystery)

    Did I say I feel stupid already? I have to keep reminding myself that if a solution to a problem seems overly complicated I’m probably approaching it all wrong.

    I didn’t find the leaf child theme until I’d already been banging my head for a while. It’s functions.php doesn’t say anything about the require statements – and yea – I know that those files ultimately end up in functions.php. Like I said – over-complicating doesn’t help.

    Still – I can’t be the only person who has been flummoxed by this. Most things you put in the child theme override the parent – why not the stuff in the includes folder (rhetorical question)?

    I’d forget the stupidity, that’s not the point.
    For me, as you, non-coders, it takes some more time to understand things about how code works, it’s normal.
    Maybe at the moment we can almost read the code, but not write it, not yet, that’s OK.
    There are people who never even get there.
    But, you didn’t read the pages I’ve linked to and you didn’t read those themes files, right?
    The answer to your last non-rhetorical question is here (same page linked above).
    Then, soon after, look at parent’s theme functions.php, that’s require_once that do the trick, I think (not assume).
    Then, once again, look at child’s theme functions.php, because isn’t true that isn’t explained… maybe shortly, but it’s explained.
    🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘modifying function leaf_comment in child theme’ is closed to new replies.