3

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.

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.

2
  • The last two sentences tell me that there is something going on in your theme(s) besides just swapping that function, which should work as you describe (which matches notes in the source). I don't know how to guess at what else might have been altered.
    – s_ha_dum
    Commented Dec 20, 2013 at 15:24
  • I suspected that. Don't know what though. The twentyten 'comments.php' contains 'wp_list_comments( array( 'callback' => 'twentyten_comment' ) );' Overridding that function in the child 'functions.php' should do the trick.
    – Joe Mohr
    Commented Dec 20, 2013 at 16:30

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.