Site logo

Archived topic

describing * in comment form

9 replies · Started by ian on February 8, 2016

Viewing posts 1–10 of 10

Hi

In the comment form There are two "*"
next to email and name

These 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

Hi 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/

Hi

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

on this site

Is that possible with GP ?

Ah, 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 :)

Thanks that is not quite in the right place

see here
http://sykic.co.uk/andbeyond/2016/01/26/boris/#comment-4

it 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

I 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 :)

Hi

Thanks yet again

Do you have a beta available somewhere to download ?

Ian

Not 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 :)

Hi

sorry its been a few days
Thank you that all works well

Just 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
Thanks

Ian

Correct, 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.

This archived topic is closed to new replies.