- This topic has 9 replies, 2 voices, and was last updated 8 years, 2 months ago by Tom.
-
AuthorPosts
-
February 8, 2016 at 6:03 am #171285ian
Hi
In the comment form There are two “*”
next to email and nameThese denote that these fields are optional
I want to put a line of text to that effect but I can’t work out where to add it there doesn’t seem a suitable hook?Ian
February 8, 2016 at 6:41 am #171311TomLead DeveloperLead DeveloperHi Ian,
You can use the comment_form_default_fields hook:
add_filter( 'comment_form_default_fields','generate_comment_form_default_fields' ); function generate_comment_form_default_fields() { $fields = array( 'author' => '<input placeholder="' . __( 'Name','generate' ) . ' *" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" />', 'email' => '<input placeholder="' . __( 'Email','generate' ) . ' *" id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" />', 'url' => '<input placeholder="' . __( 'Website','generate' ) . '" id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" />', ); return $fields; }
Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/
February 9, 2016 at 9:04 am #171575ianHi
Thanks that allows me to replace holding text within form fields
What I really would like is to be able to put a line of text above the comment form like this
Is that possible with GP ?
February 9, 2016 at 8:39 pm #171697TomLead DeveloperLead DeveloperAh, I understand.
Currently it’s not possible without making a child theme, but I’ve added a hook in the next version.
To make the change to your site currently, find the comments.php file in “Appearance > Editor”.
Find this line:
<?php // You can start editing here -- including this comment! ?>
And replace it with this line:
<?php do_action( 'generate_inside_comments' ); ?>
Now you can use this function:
add_action( 'generate_below_comments_title','generate_add_comment_desc' ); function generate_add_comment_desc() { ?> Your text for above the comments here <?php }
Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/
Hope this helps π
- This reply was modified 8 years, 2 months ago by Tom.
February 10, 2016 at 2:30 pm #171925ianThanks that is not quite in the right place
see here
http://sykic.co.uk/andbeyond/2016/01/26/boris/#comment-4it allows extra text above all the comments
what I wanted is extra text under “Leave a comment” title just above the form
Not the end of world if not possible
Ian
- This reply was modified 8 years, 2 months ago by ian.
- This reply was modified 8 years, 2 months ago by ian.
February 10, 2016 at 10:08 pm #171966TomLead DeveloperLead DeveloperI think that position warrants a hook as well.
In comments.php file the closing
</h3>
(line 32).Below it, add this:
<?php do_action( 'generate_below_comments_title' ); ?>
Then use the adjusted code I gave you above.
This will be default in the next version π
February 13, 2016 at 3:53 am #172490ianHi
Thanks yet again
Do you have a beta available somewhere to download ?
Ian
February 13, 2016 at 8:46 am #172531TomLead DeveloperLead DeveloperNot yet, but here’s the entire comments.php file: http://pastebin.com/d7LGX6z8
Just replace the contents of yours with that code and you should be good to go π
February 19, 2016 at 8:25 am #173846ianHi
sorry its been a few days
Thank you that all works wellJust to confirm. That is how it will be in the next version you release ?
Am I right in that it is not possible to uniquely format those bits of text with CSS ?
Brilliant support
ThanksIan
February 19, 2016 at 10:25 am #173877TomLead DeveloperLead DeveloperCorrect, that’s the file in the next version π
You can definitely use CSS to adjust the text, just wrap it in an HTML element with a class.
-
AuthorPosts
- You must be logged in to reply to this topic.