• Resolved Shaun Brown

    (@steezo)


    Hi, this is a pretty “noob” question unfortunately so bare with me…
    Ive created 3 themes from scratch now, however Ive never needed to implement the comments template until this project so this is a bit new to me. So with consideration to the fact that this is my first time using the comments template, Ive decided to try and make it easy on myself by simply copying over the existing comments.php and comments section of the functions.php templates to my theme.

    I understand how to get the comments template working and how to do basic CSS styling to dress it up a bit, but since my theme is totally custom – so are my comments stylings, and they dont mirror the way the original listed comments are marked up…

    Normally this would be pretty easy for me since I know what Im looking at and what to safely delete, however Im still pretty new to messing with the functions template as well as php so Im a bit confused about a few things…For example,

    *Ive dissected the source from the outputed comments in the html so I at least no where to look in the functions template, however I dont understand how certain parts of the markup work like when the <li> element is instantiated….

    I see it starts by opening the list tag, but then I cant seem to find the closing </li> tag…Can anyone explain whats going on there? Im assuming the php is helping complete that list tag but it makes no sense to me.

    *Also, any articles about the anatomy of the new comments template would be a big help if you know of any???….Ive looked through the codex but it still left me empty handed as a beginner to wordpress.

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Shaun Brown

    (@steezo)

    This is basically what Im trying to do:
    https://img263.imageshack.us/img263/1334/picture1copy.png

    I can already style most of the comments the way my mockup looks from simply using css on the existing styles, but I need to change the outputted html from the comment list in order to be able to add the little background image icons for the user name, date, and time…

    Is this possible?

    Michael

    (@alchymyth)

    the code of the comment output is in functions.php of twenty ten; from line 300
    (actually starts at line 289 with:

    if ( ! function_exists( 'twentyten_comment' ) ) :
    /**
     * Template for comments and pingbacks.
     *
     * To override this walker in a child theme without modifying the comments template
     * simply create your own twentyten_comment(), and that function will be used instead.
     *
     * Used as a callback by wp_list_comments() for displaying the comments.
     *
     * @since Twenty Ten 1.0
     */
    function twentyten_comment( $comment, $args, $depth ) {
    	$GLOBALS['comment'] = $comment;
    ...
    ...
    ...

    Thread Starter Shaun Brown

    (@steezo)

    Thanks, I previously found the template inside the functions.php a while back, my issue is Im not too sure how to go about altering that php in order to inject my own custom html so that it can look the way my mockup does.

    I basically need some help on how to make a custom callback so that I can create my own comment that isnt verbatim to the way it gets outputted right now. This is normally pretty easy stuff if I had to do this in the loop since I just markup my html and then plug in the appropriate wordpress tags to dynamically fill the rest of the content, however I dont know php enough to muck around in the functions template to re-arrange stuff or moreso completely alter it from its original look which is what I want to do.

    Michael

    (@alchymyth)

    how to make a custom callback

    this area in functions.php is the custom callback –
    called here in comments.php:

    <ol class="commentlist">
    			<?php
    				/* Loop through and list the comments. Tell wp_list_comments()
    				 * to use twentyten_comment() to format the comments.
    				 * If you want to overload this in a child theme then you can
    				 * define twentyten_comment() and that will be used instead.
    				 * See twentyten_comment() in twentyten/functions.php for more.
    				 */
    				wp_list_comments( array( 'callback' => 'twentyten_comment' ) );
    			?>
    		</ol>

    you can write your own custom callback, add it to functions.php, and then change the callback name in the eline above.

    Thread Starter Shaun Brown

    (@steezo)

    Thanks for baring with me here Alchymyth…
    Im aware of where the callback is and how to change the name, etc…
    The part Im in need of some help with however is changing the actual custom callback around…I framed the comment the way I want via html/css perfectly fine, but when I tried to remove certain parts of the callback and place my new markup in there it broke the theme….

    Thread Starter Shaun Brown

    (@steezo)

    Basically looking for an example Custom Callback, FULLY COMMENTED OUT to explain whats happening step by step in each part. Ill be able to sort the rest out from there if I can reference something like that basically.
    Thanks

    Thread Starter Shaun Brown

    (@steezo)

    In case anyone else is having trouble sorting out the same thing, here is a link to probably the only useful tutorial/article out there on the subject and it helped me out quite a bit:
    https://www.net-cake.com/creating-your-own-wordpress-comment-form

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Trying to customize the comments template from TwentyTen’ is closed to new replies.