رفتن به مطلب

اضافه كردن كد ID دسته


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

سلام خدمت بزرگواران

من يك قسمت در پوسته دارم كه كد اون به صورت زير هست و 1 نوشته با عكس + 5 نوشته (فقط موضوع ) رو در زيرش نشون ميده.

ميخوام براي اين قسمت دسته خاصي رو در نظر بگيرم تا از اون دسته پست نشون بده.

چه كدي رو كجا بايد بزارم؟

ممنون


<!-- side start -->
<div class="leftside-child">
<h2 class="acc_trigger"><div class="leftside-child-title"><li><a href="#">اخبار قوانين</a></li></div></h2>
<div class="acc_container"><div class="leftside-child-body">
<?php $my_query = new WP_Query('showposts=1');while ($my_query->have_posts()):$my_query->the_post();$do_not_duplicate = $post->ID;?>
<li><a target="_blank" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<p><?php echo limit_words(get_the_excerpt(), '35'); ?></p>
<div classs="ttumb"><?php if ( has_post_thumbnail() ) { ?>
<a target="_blank" style="float: left" class="ttumb" href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<?php } else { ?>
<a target="_blank" style="float: left" class="ttumb" href="<?php the_permalink() ?>" rel="bookmark">
<img src="<?php bloginfo(template_directory); ?>/feature-image/<?php $category = get_the_category(); echo $category[0]->cat_name; ?>.jpg" />
</a>
<?php } ?></div>
<div class="more"><a target="_blank" href="<?php the_permalink(); ?>" >متن کامل خبر</a></div>
<?php endwhile;?>
</div>
<div class="link">
<?php $my_query = new WP_Query('showposts=5');while ($my_query->have_posts()):$my_query->the_post();$do_not_duplicate = $post->ID;?>
<li><a target="_blank" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
</div> </div>
</div>
<!-- side End -->

لینک به ارسال

با سلام.

شما میتونید برای این کار از "ژنراتور کوئری ساز" بالای همین انجمن استفاده کنید.

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

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


<?php $my_query = new WP_Query('cat=1&showposts=1');while ($my_query->have_posts()):$my_query->the_post();$do_not_duplicate = $post->ID;?>

به جای 1 در cat=1 شماره دسته ای که میخواین نمایش داده بشه رو بزارین.

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

آقا بسيار ممنون

فقط يك مشكل كوچيك هست اونم اينكه اين كادر 6 خبر زير هم هست كه اولي با متن و يك تصويره و 5 تاي ديگه فقط عنوان خبر

خبر اول كه با عكس و متن هست با خبر اول از اون 5 تا مثل هم هستند. ميشه كاري كرد تو اون 5 تا ديگه او خبر اول رو نخونه؟

لینک به ارسال

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


<!-- side start -->
<div class="leftside-child">
<h2 class="acc_trigger"><div class="leftside-child-title"><li><a href="#">اخبار قوانين</a></li></div></h2>
<div class="acc_container"><div class="leftside-child-body">
<?php $my_query = new WP_Query('cat=$excat&showposts=1');while ($my_query->have_posts()):$my_query->the_post();$do_not_duplicate = $post->ID;?>
<li><a target="_blank" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<p><?php echo limit_words(get_the_excerpt(), '35'); ?></p>
<div classs="ttumb"><?php if ( has_post_thumbnail() ) { ?>
<a target="_blank" style="float: left" class="ttumb" href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<?php } else { ?>
<a target="_blank" style="float: left" class="ttumb" href="<?php the_permalink() ?>" rel="bookmark">
<img src="<?php bloginfo(template_directory); ?>/feature-image/<?php $category = get_the_category(); echo $category[0]->cat_name; ?>.jpg" />
</a>
<?php } ?></div>
<div class="more"><a target="_blank" href="<?php the_permalink(); ?>" >متن کامل خبر</a></div>
<?php endwhile;?>
</div>
<div class="link">
<?php $i = 2;$my_query = new WP_Query('cat=$excat&showposts=5');while ($my_query->have_posts()):$my_query->the_post();$do_not_duplicate = $post->ID;?>
<li><a target="_blank" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
</div> </div>
</div>
<!-- side End -->

به جای excat کد دسته مورد نظر رو قرار بدین

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

ممنون وحيد خان.

من كد رو به صورت زيرگذاشتم اما بازم دو پست اول تكراريه


<!-- side start -->
<div class="leftside-child">
<h2 class="acc_trigger"><div class="leftside-child-title"><li><a href="#">اخبار قوانين</a></li></div></h2>
<div class="acc_container"><div class="leftside-child-body">
<?php $my_query = new WP_Query('cat=$27&showposts=1');while ($my_query->have_posts()):$my_query->the_post();$do_not_duplicate = $post->ID;?>
<li><a target="_blank" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<p><?php echo limit_words(get_the_excerpt(), '35'); ?></p>
<div classs="ttumb"><?php if ( has_post_thumbnail() ) { ?>
<a target="_blank" style="float: left" class="ttumb" href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<?php } else { ?>
<a target="_blank" style="float: left" class="ttumb" href="<?php the_permalink() ?>" rel="bookmark">
<img src="<?php bloginfo(template_directory); ?>/feature-image/<?php $category = get_the_category(); echo $category[0]->cat_name; ?>.jpg" />
</a>
<?php } ?></div>
<div class="more"><a target="_blank" href="<?php the_permalink(); ?>" >متن کامل خبر</a></div>
<?php endwhile;?>
</div>
<div class="link">
<?php $i = 2;$my_query = new WP_Query('cat=$27&showposts=5');while ($my_query->have_posts()):$my_query->the_post();$do_not_duplicate = $post->ID;?>
<li><a target="_blank" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
</div> </div>
</div>
<!-- side End -->
<!-- side start -->

لینک به ارسال


<!-- side start -->
<div class="leftside-child">
<h2 class="acc_trigger"><div class="leftside-child-title"><li><a href="#">اخبار قوانين</a></li></div></h2>
<div class="acc_container"><div class="leftside-child-body">
<?php $my_query = new WP_Query('cat=1,2,3&showposts=1');while ($my_query->have_posts()):$my_query->the_post();$do_not_duplicate = $post->ID;?>
<li><a target="_blank" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<p><?php echo limit_words(get_the_excerpt(), '35'); ?></p>
<div classs="ttumb"><?php if ( has_post_thumbnail() ) { ?>
<a target="_blank" style="float: left" class="ttumb" href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<?php } else { ?>
<a target="_blank" style="float: left" class="ttumb" href="<?php the_permalink() ?>" rel="bookmark">
<img src="<?php bloginfo(template_directory); ?>/feature-image/<?php $category = get_the_category(); echo $category[0]->cat_name; ?>.jpg" />
</a>
<?php } ?></div>
<div class="more"><a target="_blank" href="<?php the_permalink(); ?>" >متن کامل خبر</a></div>
<?php endwhile;?>
</div>
<div class="link">
<?php $my_query = new WP_Query('cat=1,2,3&showposts=5');while ($my_query->have_posts()):$my_query->the_post();$do_not_duplicate = $post->ID;?>
<li><a target="_blank" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
</div> </div>
</div>
<!-- side End -->

در کدتون دو بار cat=1,2,3 تکرار شده در هر دو بجای اعداد آی دی دسته های مورد نظر را بگذارید

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

اگر کش دارید کش را پاک و غیر فعال کنید

با قرار دادن آی دی و کت یا باید برگه ارور بده و بالا نیاد و یا باید تغییر کنه و الا هنوز کد را نمی خونه

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

ببخشید متوجه مشکل نشده بودم


<!-- side start -->
<div class="leftside-child">
<h2 class="acc_trigger"><div class="leftside-child-title"><li><a href="#">اخبار قوانين</a></li></div></h2>
<div class="acc_container"><div class="leftside-child-body">
<?php $my_query = new WP_Query('cat=1,2,3&showposts=1');while ($my_query->have_posts()):$my_query->the_post();$do_not_duplicate = $post->ID;?>
<li><a target="_blank" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<p><?php echo limit_words(get_the_excerpt(), '35'); ?></p>
<div classs="ttumb"><?php if ( has_post_thumbnail() ) { ?>
<a target="_blank" style="float: left" class="ttumb" href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<?php } else { ?>
<a target="_blank" style="float: left" class="ttumb" href="<?php the_permalink() ?>" rel="bookmark">
<img src="<?php bloginfo(template_directory); ?>/feature-image/<?php $category = get_the_category(); echo $category[0]->cat_name; ?>.jpg" />
</a>
<?php } ?></div>
<div class="more"><a target="_blank" href="<?php the_permalink(); ?>" >متن کامل خبر</a></div>
<?php endwhile;?>
</div>
<div class="link">
<?php $my_query = new WP_Query('cat=1,2,3&showposts=5&offset=1');while ($my_query->have_posts()):$my_query->the_post();$do_not_duplicate = $post->ID;?>
<li><a target="_blank" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
</div> </div>
</div>
<!-- side End -->

تست کنید

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

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

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



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