رفتن به مطلب

کد اخرین مطالب کاربر ؟؟؟؟


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

سلام

من از این کد برای آخرین مطالب کاربرا استفاده میکنم


<div class="note green">
<h4>آخرین مطالب ارسالی</h4>
<ul>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
<?php the_title(); ?>
</a> </li>
<?php endwhile; else: ?>
<p>
<?php _e('پستی منتشر نشده'); ?>
</p>
<?php endif; ?>
</ul>
</div>

و در صورت نبود پست ...‌‌مینویسه پستی منتشر نشده ، میشه یک کاری کرد در صورت نبود پست کل

<div class="note green">

پنهان بشه

با تشکر

لینک به ارسال

<?php if ( have_posts() ) :?>
<div class="note green">
<h4>آخرین مطالب ارسالی</h4>
<ul>
<?php while ( have_posts() ) : the_post(); ?>
<li> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
<?php the_title(); ?>
</a> </li>
<?php endwhile; ?>
</ul>
</div>
<?php endif; ?>

  • امتیاز 3
لینک به ارسال

خیلی ممنون درست شد میشه همین کار رو واسه آخرین دیدگاهای کاربر هم انجام داد از این کد استفاده میکنم

<div class="note green">

<h4>آخرین دیدگاهای ارسالی</h4>

<ul>

<?php

$user_i = get_current_user_id();

$args = array(

'user_id' => $user_i,

'number' => 5,

'status' => 'approve'

);

$comments = get_comments($args);

foreach ($comments as $comment)

{ ?>

<li>

<a href="<?php echo get_permalink($comment->comment_post_ID ); ?>#comment-<?php echo $comment->comment_ID; ?>">

<?php echo strip_tags($comment->comment_author); ?>: <?php echo wp_html_excerpt( $comment->comment_content, 38 ); ?></a>

</li>

<?php }?>

</ul>

</div>

لینک به ارسال

<?php
$user_i = get_current_user_id();
$args = array(
'user_id' => $user_i,
'number' => 5,
'status' => 'approve'
);
$comments = get_comments($args);
if(count($comments) > 0) {
?>
<div class="note green">
<h4>آخرین دیدگاهای ارسالی</h4>
<ul>
<?php
foreach ($comments as $comment)
{ ?>
<li>
<a href="<?php echo get_permalink($comment->comment_post_ID ); ?>#comment-<?php echo $comment->comment_ID; ?>">
<?php echo strip_tags($comment->comment_author); ?>: <?php echo wp_html_excerpt( $comment->comment_content, 38 ); ?></a>
</li>
<?php }?>
</ul>
</div>
<?php } ?>

  • امتیاز 1
لینک به ارسال


<?php
$user_i = get_current_user_id();
$args = array(
'user_id' => $user_i,
'number' => 5,
'status' => 'approve'
);
$comments = get_comments($args);
if(count($comments) > 0) {
?>
<div class="note green">
<h4>آخرین دیدگاهای ارسالی</h4>
<ul>
<?php
foreach ($comments as $comment)
{ ?>
<li>
<a href="<?php echo get_permalink($comment->comment_post_ID ); ?>#comment-<?php echo $comment->comment_ID; ?>">
<?php echo strip_tags($comment->comment_author); ?>: <?php echo wp_html_excerpt( $comment->comment_content, 38 ); ?></a>
</li>
<?php }?>
</ul>
</div>
<?php } ?>

خیلی ممنون واسه کمک تون

لینک به ارسال
قوانین کلی انجمن : 6- از اسپم کردن مضوعات پرهیز کنید. جهت دریافت پاسخ صبر داشته باشید. برای تشکر از دکمه تشکر استفاده کنید.
  • امتیاز 1
لینک به ارسال

لطفا برای ارسال دیدگاه وارد شوید

شما بعد از اینکه وارد حساب کاربری خود شدید می توانید دیدگاهی ارسال کنید



ورود به حساب کاربری
×
×
  • اضافه کردن...