رفتن به مطلب

رفع مشکل عدم نمایش پینگ ها در نظرات وردپرس


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

سلام

بخش کامنت قالب من به صورت wp_list_comments هست و داخل فایل فانکشن بخش مربوط به نظرات به صورت زیر هست. اما مشکلی که وجود داره این هست که پینگ پست هایی که پینگ دارند را نشون نمیده باید چیکار کنم؟


<?php
function mytheme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body">
<?php endif; ?>
<div class="comment-author vcard">
<?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
<?php printf(__('<cite class="fn">%s</cite>'), get_comment_author_link()) ?>
<?php the_time('d M Y'); ?>
<?php if ($comment->comment_approved == '0') : ?>
<em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?></em>
<?php endif; ?>
<a class="comment-link" href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>">#</a>
<div class="reply">
<?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>
</div>
<div class="comment-text <?php
/* Only use the adminComment class from style.css if the user_id is 1 (admin) */
if (1 == $comment->user_id)
$oddcomment = "adminComment";
echo $oddcomment;
?>">
<?php comment_text() ?>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php
}

لینک به ارسال

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


<?php
function mytheme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
<p><?php _e( 'Pingback:'); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)' ), '<span class="edit-link">', '</span>' ); ?></p>
<?php
break;
default :
extract($args, EXTR_SKIP);
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body">
<?php endif; ?>
<div class="comment-author vcard">
<?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
<?php printf(__('<cite class="fn">%s</cite>'), get_comment_author_link()) ?>
<?php the_time('d M Y'); ?>
<?php if ($comment->comment_approved == '0') : ?>
<em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?></em>
<?php endif; ?>
<a class="comment-link" href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>">#</a>
<div class="reply">
<?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>
</div>
<div class="comment-text <?php
/* Only use the adminComment class from style.css if the user_id is 1 (admin) */
if (1 == $comment->user_id)
$oddcomment = "adminComment";
echo $oddcomment;
?>">
<?php comment_text() ?>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php
break;
endswitch; // end comment_type check
}

ویرایش شده توسط mehral
لینک به ارسال

اینجا با مثال توضیح داده:

http://bacsoftwareconsulting.com/blog/index.php/wordpress-cat/wordpress-how-to-separate-comments-from-trackbacks-pingbacks-using-wp_list_comments-function/

لینک به ارسال

اینجا با مثال توضیح داده:

http://bacsoftwareconsulting.com/blog/index.php/wordpress-cat/wordpress-how-to-separate-comments-from-trackbacks-pingbacks-using-wp_list_comments-function/

اینجوری که باید دوباره بخش کامنت ها رو بسازم و استایلش بدم. من فقط می خواهم تا پینگ ها بین نظرات برحسب تاریخ درج قرار بگیرند.

لینک به ارسال

با این بخش کد هم تست کردید؟

<!-- PINGS (TRACKBACKS & PINGBACKS) SECTION -->
<?php
//If there are No pings, don't display the header and the navigation. One reason is that get_comment_pages_count() function is used to calculate the
//total number of comments pages. It does not separate for pings. So when the count is 0, the navigation still shows and it mimics the comments
//section. Second reson if there are no Pings, then why display the header.
if ((get_comments_number() - comments_only_count($count)) > 0) {

echo '<h3 id="comments-title">';
printf( _n( 'One Ping to %2$s', '%1$s Pings to %2$s', get_comments_number() - comments_only_count($count), 'twentyten' ),
number_format_i18n( get_comments_number() - comments_only_count($count) ), '<em>' . get_the_title() . '</em>' );
echo '</h3>'?>

<ol class="commentlist">
<?php
wp_list_comments('type=pings&callback=twentyten_comment');
?>
</ol>
<?php
//get_pings_pages_count() is a custom function that must be added to 'functions.php' file.
if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there Comments to navigate through? ?>

<div class="navigation">
<div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">←</span> Older Pings', 'twentyten' ) ); ?></div>
<div class="nav-next"><?php next_comments_link( __( 'Newer Pings <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div>
</div><!-- .navigation -->

<?php endif; // check for comment navigation ?>
<?php } ?>

لینک به ارسال

با این بخش کد هم تست کردید؟

<!-- PINGS (TRACKBACKS & PINGBACKS) SECTION -->
<?php
//If there are No pings, don't display the header and the navigation. One reason is that get_comment_pages_count() function is used to calculate the
//total number of comments pages. It does not separate for pings. So when the count is 0, the navigation still shows and it mimics the comments
//section. Second reson if there are no Pings, then why display the header.
if ((get_comments_number() - comments_only_count($count)) > 0) {

echo '<h3 id="comments-title">';
printf( _n( 'One Ping to %2$s', '%1$s Pings to %2$s', get_comments_number() - comments_only_count($count), 'twentyten' ),
number_format_i18n( get_comments_number() - comments_only_count($count) ), '<em>' . get_the_title() . '</em>' );
echo '</h3>'?>

<ol class="commentlist">
<?php
wp_list_comments('type=pings&callback=twentyten_comment');
?>
</ol>
<?php
//get_pings_pages_count() is a custom function that must be added to 'functions.php' file.
if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there Comments to navigate through? ?>

<div class="navigation">
<div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">←</span> Older Pings', 'twentyten' ) ); ?></div>
<div class="nav-next"><?php next_comments_link( __( 'Newer Pings <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div>
</div><!-- .navigation -->

<?php endif; // check for comment navigation ?>
<?php } ?>

اینو توی comments.php بگذارم؟

لینک به ارسال

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

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

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

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

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

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

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

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

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