How to override function twentyten_comment

I am running the Twenty Ten theme. I want to override comment formatting for certain posts. After researching how to do this, I copied the twentyten_comment function from the parent theme (twentyten) into the functions.php file for my child theme (twentyten-child). To confirm that I am running the code from the child, I added code to display the word ‘child’ on the output. I also modified the parent twentyten functions.php file to output the word ‘parent’ if that code is used. (yes, I backed up the original file so I can restore it after I figure this out).

When I view a post (in this case a question) and its comment (an answer) I see the word ‘parent’ on the page rather than ‘child’ so I know that making changes to the child code is meaningless until it is the code that gets executed.

Read More

twentyten_comment is in an if(function_exists()) statement in the parent theme so I should just be able to put a function named twentyten_comment in the child functions.php file to override it.

I have not been able to effectively override the parent function. What am I missing?

I even tried changing the function name in the child functions.php file and using that name in the wp_list_comments callback in comments.php. It fails to execute.

Related posts

1 comment

  1. I was working on another part of my website and found the issue. For some reason, child functions.php was not being recognized by wordpress.

    Mine was listed in the right admin toolbar as ‘functions.php’ not as

    Theme-functions
    ‘(functions.php)’

    I copied the content, created a new ‘functions.php’ and pasted the contents into the new file; then uploaded it.

    Now it works.

Comments are closed.