رفتن به مطلب

خطا در قسمت دیدگاه پوسته


پست های پیشنهاد شده

با سلام

من یک قالب ساده ایجاد کردم ، که در قسمت دیدگاه به مشکل برخوردم

مشکل از این قراره که ، وقتی فرم قسمت دیدگا پر میشه و ارسال زده میشه

پیغام :

خطا: لطفا دیدگاهتان را بنویسید.

مواجه میشم !

ممنون میشم که راهنمایی بفرمایید

لینک به ارسال

کد مربوط به فایل comment.php


<?php // Do not delete these lines
if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Please do not load this page directly. Thanks!');
if (!empty($post->post_password)) { // if there's a password
if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
?>
<h2><?php _e('Password Protected'); ?></h2>
<p><?php _e('Enter the password to view comments.'); ?></p>
<?php return;
}
}
/* This variable is for alternating comment background */
$oddcomment = 'alt';
?>
<!-- You can start editing here. -->
<?php if ($comments) : ?>


<div class="lastcomment">
<?php wp_list_comments("type=comment&callback=mytheme_comment"); ?>
</div>

<?php /* Changes every other comment to a different class */
if ('alt' == $oddcomment) $oddcomment = '';
else $oddcomment = 'alt';
?>

<?php else : // this is displayed if there are no comments so far ?>
<?php if ('open' == $post->comment_status) : ?>
<!-- If comments are open, but there are no comments. -->
<?php else : // comments are closed ?>
<!-- If comments are closed. -->
<p class="nocomments">امکان ارسال نظر وجود ندارد</p>
<?php endif; ?>
<?php endif; ?>
</div><!--Row-->
<?php if ('open' == $post->comment_status) : ?>
<div class="row nml mywell">


<div class="user_ID"><?php cancel_comment_reply_link(); ?></div>
<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
برای ارسال نظر لطفا ابتدا <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">وارد شوید</a> <?php else : ?>
<div class="sendcomment">
<h3><i class="fa fa-comment"></i>شما هم دیدگاه خود را ارسال کنید</h3>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<?php if ( $user_ID ) : ?>
<div class="user_ID">
شما با نام کاربری <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a> وارد شده اید. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="خارج شدن">خارج می شوید ؟ »</a></div>
<?php else : ?>
<div class="rightsend">
<input type="text" name="author" placeholder="نام شما">
<input type="email" name="email" placeholder="آدرس ایمیل">
<input type="url" name="url" placeholder="وب سایت">
</div>
<?php endif; ?>
<textarea placeholder="متن پیام شما ..."></textarea>
<input type="submit" value="ارسال دیدگاه"> <br />
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
<?php comment_id_fields(); ?>
<?php do_action('comment_form', $post->ID); ?>
</form>
</div>
<?php endif; // If registration required and not logged in ?>
<?php endif; // if you delete this the sky will fall on your head ?>


لینک به ارسال

مشکل اینه که قسمت وارد کرد متن شما از name استفاده نمیکنه و به خاطر همین متغیر $_POST['comment'] خالی برمیگردونه .

کد زیر رو پاک کنید:


<textarea placeholder="متن پیام شما ..."></textarea>

و کد زیر رو بذارید جاش :


<textarea name="comment" placeholder="متن پیام شما ..."></textarea>

لینک به ارسال

مشکل اینه که قسمت وارد کرد متن شما از name استفاده نمیکنه و به خاطر همین متغیر $_POST['comment'] خالی برمیگردونه .

کد زیر رو پاک کنید:

ممنون مشکل حل شد

فقط موضوعی که هست اینه که بعد از ثبت دیدگاه هیچ پیغامی داده نمیشه ، که مثلا دیدگاه منتظر بررسی مدیر است و ...

لینک به ارسال

از این کد استفاده کنید :


<?php
// Do not delete these lines
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
die ('Please do not load this page directly. Thanks!');
if ( post_password_required() ) { ?>
<p class="nocomments" ><?php _e('This post is password protected. Enter the password to view comments.'); ?></p>
<?php
return;
}
?>
<?php if ( have_comments() ) : ?>
<h3 id="comments"><?php printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', get_comments_number() ),
number_format_i18n( get_comments_number() ), '“' . get_the_title() . '”' ); ?></h3>
<div class="navigation">
<div class="alignleft"><?php previous_comments_link() ?></div>
<div class="alignright"><?php next_comments_link() ?></div>
</div>
<ol class="commentlist">
<?php wp_list_comments(//"callback=CALLBACK_FUNCTION");?>
</ol>
<div class="navigation">
<div class="alignleft"><?php previous_comments_link() ?></div>
<div class="alignright"><?php next_comments_link() ?></div>
</div>
<?php else : // this is displayed if there are no comments so far ?>
<?php if ( comments_open() ) : ?>
<!-- If comments are open, but there are no comments. -->

<?php else : // comments are closed ?>
<!-- If comments are closed. -->
<p class="nocomments"><?php _e('Comments are closed.'); ?></p>
<?php endif; ?>
<?php endif; ?>
<?php if ( comments_open() ) : ?>
<div id="respond">
<h3><?php comment_form_title( __('Leave a Reply'), __('Leave a Reply to %s' ) ); ?></h3>
<div id="cancel-comment-reply">
<small><?php cancel_comment_reply_link() ?></small>
</div>
<?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
<p><?php printf(__('You must be <a href="%s">logged in</a> to post a comment.'), wp_login_url( get_permalink() )); ?></p>
<?php else : ?>
<form action="<?php echo site_url(); ?>/wp-comments-post.php" method="post" id="commentform">
<?php if ( is_user_logged_in() ) : ?>
<p><?php printf(__('Logged in as <a href="%1$s">%2$s</a>.'), get_edit_user_link(), $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php esc_attr_e('Log out of this account'); ?>">
<?php _e('Log out »'); ?></a></p>
<?php else : ?>
<p><input type="text" name="author" class="comment-field" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true' required"; ?> />
<label for="author"><small><?php _e('Name'); ?> <?php if ($req) _e('(required)'); ?></small></label></p>
<p><input type="email" class="comment-field" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true' required"; ?> />
<label for="email"><small><?php _e('Mail (will not be published)'); ?> <?php if ($req) _e('(required)'); ?></small></label></p>
<p><input type="url" class="comment-field" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3" />
<label for="url"><small><?php _e('Website'); ?></small></label></p>
<?php endif; ?>
<p><small><?php printf(__('<strong>XHTML:</strong> You can use these tags: <code>%s</code>'), allowed_tags()); ?></small></p>
<p><textarea name="comment" class="comment-field textarea" id="comment" cols="58" rows="10" tabindex="4"></textarea></p>
<p><input name="submit" type="submit" id="submit" tabindex="5" class="submit-button" value="<?php esc_attr_e('Submit Comment'); ?>" />
<?php comment_id_fields(); ?>
</p>
<?php do_action('comment_form', $post->ID); ?>
</form>
<?php endif; // If registration required and not logged in ?>
</div>
<?php endif; // if you delete this the sky will fall on your head ?>

لینک به ارسال
  • 2 هفته بعد...

به گفتگو بپیوندید

هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .

مهمان
ارسال پاسخ به این موضوع ...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  تنها استفاده از 75 اموجی مجاز می باشد.

×   لینک شما به صورت اتوماتیک جای گذاری شد.   نمایش به صورت لینک

×   محتوای قبلی شما بازگردانی شد.   پاک کردن محتوای ویرایشگر

×   شما مستقیما نمی توانید تصویر خود را قرار دهید. یا آن را اینجا بارگذاری کنید یا از یک URL قرار دهید.

×
×
  • اضافه کردن...