Forum Replies Created

Viewing 5 replies - 31 through 35 (of 35 total)
  • Thread Starter evamusby

    (@evamusby)

    I hope this is OK with everyone. I have searched quite a bit on the forum and realise there are plenty of people like me who have become frustrated at this level. They get referred to the codex for function parameters and it means nothing to them. They find help on creating a child theme but not on how to use it. I found some bits of answers here and there and have pieced it all together to help others who are at my rather ignorant level.

    If anyone finds I’ve done something unorthodox, please chip in.
    I’ve put all this in action, with slightly different words, on https://www.evamusby.co.uk
    Here goes:

    Say I’m wanting to change a bit in the Comments area, where the user is asked for their email. I search everywhere for the words ‘Email’, or “Leave a Reply” and find that these and all the other comments form stuff is in folder “wp-includes”, in file “comment-template.php”
    Notice that the stuff I want to change (e.g. the word “Email”) is within a function in this file, it’s written: “function comment_form”.

    Note: Search the www.remarpro.com Codex for comment-form: there’s a page explaining the various parameters, and for people like me it takes a while to understand, which is why I’m making my own notes of what to do next.

    Now I search in folder “wp-content/themes/twentyeleven” (because the theme I use is twentyeleven) for a file that calls up this function, i.e. search for the word “comment_form”.

    A good place to look for might be in “functions.php”, but instead I find it here: in file “wp-content/themes/twentyeleven/comments.php”. It’s at the bottom, in this line:
    <?php comment_form(); ?>

    This is the bit to modify, but don’t modify it here, or it will be lost at the next theme update. Instead, modify it in a child folder as follows.

    Create a child folder inside the themes folder :” wp-content/themes/my-child” You can name it whatever you like, but in this example it’s named “my-child”.
    Inside this child folder, create a file named “comments.php” . This is the one to work on.

    Type the first few lines in the file like this:

    <?php
    /* These are my notes on how I changed the comment form.
    I am quite a beginner but I hope this will help other beginners.
    */
    ?>

    Next, here’s how I changed various parts of the comment form:

    <!—Here are some of my changes.
    This is to change what the visitor sees in the comment form area: the instruction (for author, email, url, comment field) and in some cases, the size of the text box
    –>
    <?php $comment_args = array( ‘fields’ => apply_filters( ‘comment_form_default_fields’, array(

    ‘author’ => ‘<p class=”comment-form-author”>’ . ‘<label for=”author”>’ . __( ‘Please type in your name’ ) . ‘</label> ‘ . ( $req ? ‘<span class=”required”>*</span>’ : ” ) .
    ‘<input id=”author” name=”author” type=”text” value=”‘ . esc_attr( $commenter[‘comment_author’] ) . ‘” size=”130″‘ . $aria_req . ‘ /></p>’,

    ’email’ => ‘<p class=”comment-form-email”><label for=”email”>’ . __( ‘Please type in your mail (it won\’t be displayed)’ ) . ‘</label> ‘ . ( $req ? ‘<span class=”required”>*</span>’ : ” ) .
    ‘<input id=”email” name=”email” type=”text” value=”‘ . esc_attr( $commenter[‘comment_author_email’] ) . ‘” size=”30″‘ . $aria_req . ‘ /></p>’,

    ‘url’ => ‘<p class=”comment-form-url”><label for=”url”>’ . __( ‘Please type in your website’ ) . ‘</label>’ .
    ‘<input id=”url” name=”url” type=”text” value=”‘ . esc_attr( $commenter[‘comment_author_url’] ) . ‘” size=”30″ /></p>’,

    //Note the two brackets and the comma here

    ) ),
    //Now I can change some of the other things in the form. Note that here I can change the number of columns too, in other words how large the box is

    ‘comment_field’ => ‘<p class=”comment-form-comment”><label for=”comment”>’ . _x( ‘ Go on, write a comment’, ‘noun’ ) . ‘</label><textarea id=”comment” name=”comment” cols=”45″ rows=”8″ aria-required=”true”></textarea></p>’,

    //The following shows how I can put a link in too

    ‘comment_notes_before’ => ‘<p class=”comment-notes”>’ . __( ‘Check out my comments policy here.’ ) . ( $req ? $required_text : ” ) . ‘</p>’,

    //Note the bracket and the comma here, right at the end

    );
    comment_form($comment_args); ?>

    And that’s the last line. I hope the above works for you.
    Note that if you want to remove parts of what normally appears, for instance to remove the bit that asks a user for their website: you’d replace what I put earlier in the line starting ‘url’ => ‘lots of stuff here'</p>, and replace it with

    ‘url’ => ”,

    Thread Starter evamusby

    (@evamusby)

    Thanks, I’ll give it a try, though I suspect I’m missing some more fundamental thing about HOW to change the bits I want to change. Bedtime for me now though.
    Thanks you again

    Thread Starter evamusby

    (@evamusby)

    Thank you Esmi. See these pages you are suggesting I look at? I would love to understand them, because so far I haven’t used anything like this and it’s getting me stuck.

    So I have one question which may, by example, help me understand how all this works.
    See in that comment-form()page you’ve linked to, there’s this:

    comment_field
    (string) (optional) The textarea and the label of comment body.
    Default:
    ‘<p class=”comment-form-comment”><label for=”comment”>’ . _x( ‘Comment’, ‘noun’ ) . ‘</label><textarea id=”comment” name=”comment” cols=”45″ rows=”8″ aria-required=”true”></textarea></p>’

    Say I want to change the default “Comment” to “Reply” then can you tell me where/how I do this?
    As I said earlier, the way I’ve done it up to now is found a line [saying ‘comment_field’=> ‘<p class etc etc ] in file comment-template.php inside the wp-includes folder and that’s what I’ve been naively editing.

    I’m hoping if I understand this I’ll understand loads of other similar things, so thanks for any help. (And I’m afraid I don’t understand what you mean by “You may need to make your changes via a custom comments.php template file or functions.php file in your child theme.” Though I do have a functions.php file in a child folder I created within wp-content/themes)
    Thanks
    Eva

    Thread Starter evamusby

    (@evamusby)

    Ah, OK, thanks.
    So could anyone advise me how to make changes using a child folder in this situation?
    For example I want to change stuff that’s presently in wp-includes/comment-template.php . I take it I create a new file comment-template.php with the changes in it? And I put that file where? Anything else that I need to do so that file gets put to work?

    Just so you know what (poor) level of knowledge I have, at present I have a folder I called “mine-tewentyeleven-child” and it’s in the wp-content/themes folder, and it contains a modified style.css, a single.php, and a functions.php, each containing my changes. Where I’m stuck is what happens when the file I want to change is in the wp-includes folder.

    By the way, I am bowled over by wordpress, what it does, and that it’s the result of so much generosity from people.
    Eva

    Thread Starter evamusby

    (@evamusby)

    Absolutely need it? No ?? But I’m impressed with how convenient the hover/larger image is on Google Image search, Corbis etc, so that’s what I’m hoping for as a first choice.

Viewing 5 replies - 31 through 35 (of 35 total)