Is there any way to customize wordpress twentytwelve_comment function to change default comment author meta details.
1 Answer
The quick answer would probably be 'yes' – although it is not recommended to customize a wordpress function directly a.k.a. "hack the core".
I would strongly recommend you use a child theme to override the comments template "comments.php" which is afaik the only template actually using the function twentytwelve_comment. You could then call your own comments function inside your custom child template "comments.php" instead of calling the default twentytwelve_comment.
A good strat to find out more about creating child themes would be the codex: https://codex.wordpress.org/Child_Themes or you could download a 'bones' child theme of twentytwelve over here: http://hyperlinkcode.com/blog/free-bare-bones-child-theme-for-twenty-twelve/. Then simply copy the template "comments.php" into your child theme directory and adjust it according to your preferences.
To be a bit more specific:
Open the file 'functions.php' from your parent theme foder. Around line 258 you should see the beginning of the function "twentytwelve_comment" like this:
if ( ! function_exists( 'twentytwelve_comment' ) ) :
Copy the function to your 'functions.php' inside your child theme and rename it so it does not interfear with the original function – for example "mytheme_comment".
Then copy the comments tempate "comments.php" to your child theme. Inside the template around line 37 you need to change what function is called to actually list the comments.
Before:
<?php wp_list_comments( array( 'callback' => 'twentytwelve_comment', 'style' => 'ol' ) ); ?>
After:
<?php wp_list_comments( array( 'callback' => 'mytheme_comment', 'style' => 'ol' ) ); ?>
Now you could basically make whatever change to your comments function "mytheme_comment" without changing the parent theme…
-
I am already using child theme. But kindly tell me how to do this. Jun 28, 2016 at 14:50
-
I added some more details above – hope this helps to get you started… Jun 28, 2016 at 15:39