in ,

Full HD How To Add Comment Function Without Plugins

HD Video of How To Add Comment Function Without Plugins on e akhabaar

Whenever you share a post on your WordPress website, then someone can comment if you want to comment on that post. Then it is necessary to have a comment box to comment.

If you want to put a comment box or comment function in your WordPress theme, then follow the steps given below.

1 – function.php

First, you paste the code below in function.php.

/Change the comment reply link to use 'Reply to '
*/
function add_comment_author_to_reply_link($link, $args, $comment)

$comment = get_comment( $comment );

// If no comment author is blank, use 'Anonymous'
if ( empty($comment->comment_author) ) 
if (!empty($comment->user_id))
$user=get_userdata($comment->user_id);
$author=$user->user_login;
 else 
$author = __('Anonymous');

 else 
$author = $comment->comment_author;


// If the user provided more than a first name, use only first name
if(strpos($author, ' '))
$author = substr($author, 0, strpos($author, ' '));


// Replace Reply Link with "Reply to "
$reply_link_text = $args['reply_text'];
$link = str_replace($reply_link_text, 'Reply to ' . $author, $link);

return $link;

add_filter('comment_reply_link', 'add_comment_author_to_reply_link', 10, 3);

2 – comments. php

Now you Create comment.php file and paste given code


    100, 'style' => 'ol', 'short_ping' => true, 'reply_text' => __( 'Reply', 'nd_dosth' ), ) ); ?>
'' . __( 'Previous', 'nd_dosth' ) . '', 'next_text' => '' . __( 'Next', 'nd_dosth' ) . '', ) ); endif; // Check for have_comments(). // If comments are closed and there are comments, let's leave a little note, shall we? if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?>

3 – style.css

Now you paste the code below in style.css

#respond h3, .comments-title
color:black;
padding: 20px;
font-size: 20px;
border-top:1px solid #000;
border-bottom:1px solid #000;
margin: 30px 0;

#commentform .comment-notes
margin-bottom: 20px;

#commentform label
display:block;

#commentform input[type="text"],
#commentform input[type="url"],
#commentform input[type="email"],
#commentform textarea
border: 1px solid #ccc;
border-radius: 4px;
margin-bottom: 20px;
width: 100%;
background-color: #f8f8f8;
padding: 7px 10px;
font-size: 18px;

#commentform input[type="submit"]
line-height: 38px;
border-radius: 4px;
padding: 0 20px;
background-color: #fdb813;
color: black;
font-weight: bold;
font-size: 16px;
border:0;
position: relative;
transition:all 0.4s;
cursor:pointer;

#commentform input[type="submit"]:hover
background-color: #6e551a;
color: white;

.comment-body .comment-author
float:left;
width: 30%;

.comment-body .comment-author .fn
display:block;
margin-top: 10px;

.comment-body
overflow:hidden;
margin-bottom: 30px;

.comment
margin-bottom: 30px;

.comment-list, .children
margin:0;
padding:0;
list-style-type: none;

.comment-list > li:first-child
border-top:0;
padding-top:0;

.comment
border-top:1px solid #ccc;
padding-top: 30px;
position:relative;

.children .comment
border-top:0;

.comment .children
border-top:1px dotted #5e666b;
border-left:1px dotted #5e666b;
padding-top: 10px;
padding-left: 10px;

.children
margin-left: 100px;

.children img
max-width: 75px;
height:auto;

.children .fn
font-size: 12px;

.says
display:none;

.comment-metadata
margin-left: 30%;

.comment-metadata a
color:#5e666b;
font-size: 14px;
margin-bottom: 10px;
display:block;

.comment-reply-link
position:absolute;
top: 15px;
right:0;
font-size: 12px;
color:#1a3794;

4 – single.php

Now paste the below code into single.php

In this way, you can put a comment box without any plugins.

Give your review about How To Add Comment Function Without Plugins in Comments below

Guest

Written by Guest