انجمن


نمایش آخرین comment فقط  (۱۱ نوشته)

  • 611

    آفلاین
    عضو
    تعداد نوشته‌ها: ۴۵
    تشکر شده: ۴ بار
    # نوشته شده: ۱۶ سال پیش
    ۱ فروردین ۱۳۸۷ - ۱۴:۵۸

    میخوام فقط آخرین comment هر پست در پایین هر مطلب نمایش داده شود .

    یعنی با اضافه شدت کامنت جدید، کامنت قبلی نمایش داده نشود.

    comments.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
    				?>
    
    				<div class="box">
    					<h2><?php _e('Protected Post'); ?></h2>
    					<p><?php _e("This post is password protected. Enter the password to view comments."); ?><p>
    				</div>
    
    				<?php
    				return;
                }
            }
    ?>
    
    <a name="comments"></a>
    
    <? /* Comments and Trackbacks */ ?>
    
    <?php if ( $comments ) :			// If there are comments ?>
    
    <div class="box"><?php // Open box container ?>
    
    		<?php include (TEMPLATEPATH . '/template-trackbacks.php'); ?>
    
    		<?php include (TEMPLATEPATH . '/template-comments.php'); ?>
    
    <?php else : 						// If there are no comments yet ?>
    
    <?php /*
    <div class="box"><?php // Open box container ?>
    	<p><?php _e('No comments yet.'); ?></p>
    */ ?>
    
    <?php endif; ?>
    
    <? /* Commentform */ ?>
    <?php if ( comments_open() ) :	// Comments are open, show the commentform ?>
    
    		<?php if (!$comments) { ?><div class="box"><?php }
    			// If there are no comments, then the box container wasn't opened, open it here ?>
    
    		<?php include (TEMPLATEPATH . '/template-commentform.php'); ?>
    
    		</div><?php // Close the box container after the commentform ?>
    
    	<?php else : 				// Comments are closed, don't show the commentform ?>
    
    			<? /*
    			<p><?php _e('Comments are not allowed at this time.'); ?></p>
    			*/ ?>
    
    		<?php if ($comments) { ?></div><?php }
    			// If there are comments, then the box container was opened,
    			// but comments are closed so the commentform above isn't closing it,
    			// so close it here ?>
    
    <?php endif; ?>

    template-comments.php

    <?php /*
    	Comments Template
    	This page holds the code used by comments.php for showing comments.
    	It's separated out here for ease of use, because the comments.php file is already pretty cluttered.
    	*/
    ?>
    
    <?php
    	$even = "comment-even";
    	$odd = "comment-odd";
    	$author = "comment-author";
    	$bgcolor = $even;
    ?>
    
    <?php foreach ($comments as $comment) : ?>
    	<?php if ($comment->comment_type != "trackback" && $comment->comment_type != "pingback") {
    			// Show only comments, not trackbacks ?>
    
    <?php if (!$runonce_comments) { $runonce_comments = true; ?>
    <h2 id="comments"><?php _e('Comments') ?></h2>
    <ol id="commentlist">
    <?php } ?>
    
    	<?php /* Comment number and bg colors */
    	$comment_number++;
    	if($odd == $bgcolor) { $bgcolor = $even; } else { $bgcolor = $odd; }
    
    	/* Assign .comment-author CSS class to weblog administrator */
    	$is_author = false;
    	if($comment->comment_author_email == get_settings(admin_email)) {
    		$is_author = true;
    	}
    	?>	
    
    	<li class="<?php if ($is_author == true) { echo $author; } else { echo $bgcolor; }?>">
    		<a name="comment-<?php comment_ID() ?>"></a>
    		<div class="comment-body">
    			<div class="comment-header">
    
    				<?php if (function_exists('gravatar')) { ?>
    
    					<a href="<?php echo($comment->comment_author_url); ?>" title="<?php _e('Visit') ?> <?php echo($comment->comment_author); ?>" class="comment-gravatar">
    						<img src="<?php gravatar("R", 40); ?>" alt="" />
    					</a>
    
    				<?php } else if (function_exists('comment_favicon')) { ?>
    
    					<a href="<?php echo($comment->comment_author_url); ?>" title="<?php _e('Visit') ?> <?php echo($comment->comment_author); ?>">
    						<?php comment_favicon($before='<img src="', $after='" alt="" class="comment-favatar" />'); ?>
    					</a>
    
    				<?php } ?>
    
    				<em><a href="#comment-<?php echo($comment->comment_ID) ?>" title="<?php _e('Permanent link to this comment') ?>"><?php echo($comment_number) ?></a></em>
    				<strong><?php comment_author_link(); ?></strong>
    				<?php if ( function_exists(comment_subscription_status) ) { if (comment_subscription_status()) { ?><?php _e('(subscribed to comments)') ?><?php }} ?>
    				<?php _e('says:') ?>
    
    				<?php if ($comment->comment_approved == '0') : ?>
    				<small><?php _e('Your comment is awaiting moderation. This is just a spam counter-measure, and will only happen the first time you post here. Your comment will be approved as soon as possible.') ?></small>
    				<?php endif; ?>
    
    			</div>
    
    			<div id="comment-<?php comment_ID() ?>"><?php comment_text() ?></div>
    
    			<small>
    				<?php if (comments_open()) { ?>&darr; <a href="#respond" title="<?php _e('Quote this comment') ?>" onclick="quote('comment-<?php comment_ID() ?>', '<?php echo($comment->comment_author); ?>')"><?php _e('Quote') ?></a> | <?php } ?>
    
    				<?php if (function_exists("jal_edit_comment_link")) { ?>
    				<?php jal_edit_comment_link(__("Edit Comment"), ' ', ' | '); ?>
    				<?php } else { ?>
    				<?php edit_comment_link(__("Edit Comment"), ' ', ' | '); ?>
    				<?php } ?>
    
    				<?php _e('Posted') ?>
    				<?php if (function_exists('time_since')) {
    				echo time_since(abs(strtotime($comment->comment_date_gmt . " GMT")), time()) . " ago";
    				} else { ?>
    				<?php comment_date(); ?>, <?php comment_time(); } ?> 
    
    			</small>
    		</div>
    	</li>
    
    	<?php } ?>
    <?php endforeach; ?>
    
    	<? if ($runonce_comments) { ?>
    	</ol>
    	<? } ?>

    ممنون میشم ، اگه کمکم کنید.

  • ahmad1369

    آفلاین
    عضو
    تعداد نوشته‌ها: ۱۴۸
    تشکر شده: ۱۲ بار
    # نوشته شده: ۱۶ سال پیش
    ۲ فروردین ۱۳۸۷ - ۱۴:۰۵

    میشه همه ی نظرات را زیر هر مطلب نشون داد ولی اینی که شما می خواهید بعید می دونم عملی باشه. :-?

  • shahvar

    آفلاین
    عضو
    تعداد نوشته‌ها: ۲۶۶
    تشکر شده: ۲۱ بار
    # نوشته شده: ۱۶ سال پیش
    ۲ فروردین ۱۳۸۷ - ۱۶:۴۷

    نخير .... راه داره

  • ahmad1369

    آفلاین
    عضو
    تعداد نوشته‌ها: ۱۴۸
    تشکر شده: ۱۲ بار
    # نوشته شده: ۱۶ سال پیش
    ۲ فروردین ۱۳۸۷ - ۱۷:۱۶

    shahvar گفت:
    نخير .... راه داره

    خوب راهش چیه ؟

  • akmeghdad

    آفلاین
    عضو
    تعداد نوشته‌ها: ۱۱۳
    تشکر شده: ۵ بار
    # نوشته شده: ۱۶ سال پیش
    ۲ فروردین ۱۳۸۷ - ۱۷:۵۵

    خوب راهش چیه ؟

    برنامه نویسی :D

  • akmeghdad

    آفلاین
    عضو
    تعداد نوشته‌ها: ۱۱۳
    تشکر شده: ۵ بار
    # نوشته شده: ۱۶ سال پیش
    ۲ فروردین ۱۳۸۷ - ۱۸:۱۳

    وقت کنم برات درستش می کنم

  • 611

    آفلاین
    عضو
    تعداد نوشته‌ها: ۴۵
    تشکر شده: ۴ بار
    # نوشته شده: ۱۶ سال پیش
    ۴ فروردین ۱۳۸۷ - ۰۲:۳۰

    اگر کمک کنی ممنون میشم

  • گناهکار

    آفلاین
    کلیددار
    تعداد نوشته‌ها: ۳۵۳۵
    تشکر شده: ۲۵۴۴ بار
    # نوشته شده: ۱۶ سال پیش
    ۴ فروردین ۱۳۸۷ - ۱۵:۱۳

    این کد رو جایگزین محتوای فعلی template-comments.php کنین٬ ببینین مشکل حل می‌شه یا نه٬ البته چون من قالب شما رو ندارم نتونستم تست کنم اما از نظر منطقی باید این دستور کار کنه:

    <?php /*
    	Comments Template
    	This page holds the code used by comments.php for showing comments.
    	It's separated out here for ease of use, because the comments.php file is already pretty cluttered.
    	*/
    ?>
    
    <?php
    	$even = "comment-even";
    	$odd = "comment-odd";
    	$author = "comment-author";
    	$bgcolor = $even;
    ?>
    <?php $i = 1; ?>
    <?php foreach ($comments as $comment) : ?>
    	<?php if ($comment->comment_type != "trackback" && $comment->comment_type != "pingback") {
    
    			// Show only comments, not trackbacks ?>
    
    <?php if (!$runonce_comments) { $runonce_comments = true; ?>
    <h2 id="comments"><?php _e('Comments') ?></h2>
    <ol id="commentlist">
    <?php } ?>
    
    	<?php /* Comment number and bg colors */
    	$comment_number++;
    	if($odd == $bgcolor) { $bgcolor = $even; } else { $bgcolor = $odd; }
    
    	/* Assign .comment-author CSS class to weblog administrator */
    	$is_author = false;
    	if($comment->comment_author_email == get_settings(admin_email)) {
    		$is_author = true;
    	}
    	?>
    	<?php if($i == get_comments_number(get_the_ID())) : ?>
    	<li class="<?php if ($is_author == true) { echo $author; } else { echo $bgcolor; }?>">
    		<a name="comment-<?php comment_ID() ?>"></a>
    		<div class="comment-body">
    			<div class="comment-header">
    
    				<?php if (function_exists('gravatar')) { ?>
    
    					<a href="<?php echo($comment->comment_author_url); ?>" title="<?php _e('Visit') ?> <?php echo($comment->comment_author); ?>" class="comment-gravatar">
    						<img src="<?php gravatar("R", 40); ?>" alt="" />
    					</a>
    
    				<?php } else if (function_exists('comment_favicon')) { ?>
    
    					<a href="<?php echo($comment->comment_author_url); ?>" title="<?php _e('Visit') ?> <?php echo($comment->comment_author); ?>">
    						<?php comment_favicon($before='<img src="', $after='" alt="" class="comment-favatar" />'); ?>
    					</a>
    
    				<?php } ?>
    
    				<em><a href="#comment-<?php echo($comment->comment_ID) ?>" title="<?php _e('Permanent link to this comment') ?>"><?php echo($comment_number) ?></a></em>
    				<strong><?php comment_author_link(); ?></strong>
    				<?php if ( function_exists(comment_subscription_status) ) { if (comment_subscription_status()) { ?><?php _e('(subscribed to comments)') ?><?php }} ?>
    				<?php _e('says:') ?>
    
    				<?php if ($comment->comment_approved == '0') : ?>
    				<small><?php _e('Your comment is awaiting moderation. This is just a spam counter-measure, and will only happen the first time you post here. Your comment will be approved as soon as possible.') ?></small>
    				<?php endif; ?>
    
    			</div>
    
    			<div id="comment-<?php comment_ID() ?>"><?php comment_text() ?></div>
    
    			<small>
    				<?php if (comments_open()) { ?>&darr; <a href="#respond" title="<?php _e('Quote this comment') ?>" onclick="quote('comment-<?php comment_ID() ?>', '<?php echo($comment->comment_author); ?>')"><?php _e('Quote') ?></a> | <?php } ?>
    
    				<?php if (function_exists("jal_edit_comment_link")) { ?>
    				<?php jal_edit_comment_link(__("Edit Comment"), ' ', ' | '); ?>
    				<?php } else { ?>
    				<?php edit_comment_link(__("Edit Comment"), ' ', ' | '); ?>
    				<?php } ?>
    
    				<?php _e('Posted') ?>
    				<?php if (function_exists('time_since')) {
    				echo time_since(abs(strtotime($comment->comment_date_gmt . " GMT")), time()) . " ago";
    				} else { ?>
    				<?php comment_date(); ?>, <?php comment_time(); } ?> 
    
    			</small>
    		</div>
    	</li>
    	<?php endif; ?>
    	<?php } ?>
        <?php $i++; ?>
    <?php endforeach; ?>
    
    	<? if ($runonce_comments) { ?>
    	</ol>
    	<? } ?>
  • 611

    آفلاین
    عضو
    تعداد نوشته‌ها: ۴۵
    تشکر شده: ۴ بار
    # نوشته شده: ۱۶ سال پیش
    ۴ فروردین ۱۳۸۷ - ۱۷:۰۹

    درست شد، مرسی .کارت مثله وبلاگت درسته :)

  • گناهکار

    آفلاین
    کلیددار
    تعداد نوشته‌ها: ۳۵۳۵
    تشکر شده: ۲۵۴۴ بار
    # نوشته شده: ۱۶ سال پیش
    ۴ فروردین ۱۳۸۷ - ۲۰:۴۴

    خواهش می‌کنم :)

  • ahmad1369

    آفلاین
    عضو
    تعداد نوشته‌ها: ۱۴۸
    تشکر شده: ۱۲ بار
    # نوشته شده: ۱۶ سال پیش
    ۵ فروردین ۱۳۸۷ - ۰۲:۵۷

    ملت دمتون گرم سه سوته کار همه را راه می اندازید @},-

درباره‌ی این موضوع



برچسب‌ها

هیچ برچسبی نیست.