رفتن به مطلب

جایگزین مطالب تصادفی به جای دیگر نوشته ها


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

سلام

توی سایت من

http://www.lawgostar.com/main/

زیر نوشته ها ی قسمتی هست زده دیگر نوشته ها ولی به صورت عکس هست نه نوشته و من میخام جای این قسمت مطالب تصادقی بیاد و به صورت نوشته باشه میشه راهنمائی کنید

لینک به ارسال

سلام.کد زیر رو در محل مورد نظر کپی کنید


<?php
global $post;
$myposts = get_posts('showposts=12&orderby=rand');
foreach($myposts as $post) :
setup_postdata($post);?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
<?php wp_reset_query(); ?>
</ul>

در کد بالای در showpost=12 جای عدد 12 می تونید تعداد پستی که می خواید نمایش داده بشه قرار بدید

ویرایش شده توسط A_Corleone
  • امتیاز 3
لینک به ارسال

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

لینک به ارسال

قالب که فارسی شده اش موجوده شما برای چی دوباره فارسیش کردین؟! http://www.higgs.ir/...olio/webcolors/

من قالب رو که از این بالا دانلود کردم و مشاهده کردم اون قسمت دیگر نوشته ها در پوشه ی templates و کوئری مطالب در فایل random.php موجوده کدها رو در این فایل ویرایش کنید و کد بالا رو که دادم جایگزین کنید

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

ویرایش شده توسط A_Corleone
  • امتیاز 1
لینک به ارسال

سلام.

دوست عزیز من عوض کردم ولی اعمال نشد شما لطفا زحمتش را بکش راستی میخام تصویرشاخص نباشه کلا میخام تیترباشه

templates


<div id="AuthorMainwidget">
<div id="AuthorContent">
<div class="authorInformation">
<span class="AuthorName"><?php _e('توسط : ','lawgostar'); ?><?php the_author(); ?></span>
<div class="postAuthorMain">
<?php echo get_avatar( get_the_author_meta( 'user_email' ), '64' ); ?>
</div>
<p class="before">
<?php the_author_description(); ?>
</p>
</div><!--End authorInformation-->
<div class="AuthorMore">
<?php _e('مشاهده همه مطالب ','lawgostar'); ?><?php the_author_posts_link(); ?>
</div>
</div><!--End Author-->
</div><!--End AuthorMainwidget-->

random.php


<div id="otherPosts">
<div class="otherPostsTitle">
<a href="#"><h2><?php _e('آخرین مطالب','lawgostar'); ?></h2></a>
</div><!--End Other Posts Title-->
<div class="otherPostsContent">
<?php
$rand_posts = get_posts('numberposts=16&orderby=rand');
foreach( $rand_posts as $post ) : ?>
<div class="otherPost">
<a href="<?php the_permalink();?>"><?php the_post_thumbnail(); ?></a>
</div><!--End OtherPost-->
<?php endforeach; ?>
</div><!--End Other Posts Content-->
</div><!--End Other Posts-->

لینک به ارسال

كد زير براي مطالب تصادفي تست كنيد:


<div id="otherPosts">
<div class="otherPostsTitle">
<a href="#"><h2><?php _e('آخرین مطالب','lawgostar'); ?></h2></a>
</div><!--End Other Posts Title-->
<div class="otherPostsContent">
<div class="otherPost">
<?php
global $post;
$myposts = get_posts('showposts=12&orderby=rand');
foreach($myposts as $post) :
setup_postdata($post);?>
<a href="<?php the_permalink();?>"><?php the_post_thumbnail(); ?></a>
<?php endforeach; ?>
<?php wp_reset_query(); ?>
</div><!--End OtherPost-->
</div><!--End Other Posts Content-->
</div><!--End Other Posts-->

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

کدهای random.php رو حذف کنید و کد زیر رو جایگزین کنید و تست کنید


<div id="otherPosts">
<div class="otherPostsTitle">
<a href="#"><h2><?php _e('مطالب تصادفی','lawgostar'); ?></h2></a>
</div><!--End Other Posts Title-->
<div class="otherPostsContent">
<ul>
<?php
global $post;
$myposts = get_posts('showposts=12&orderby=rand');
foreach($myposts as $post) :
setup_postdata($post);?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
<?php wp_reset_query(); ?>
</ul>
</div><!--End Other Posts Content-->
</div><!--End Other Posts-->

ویرایش شده توسط A_Corleone
  • امتیاز 5
لینک به ارسال

دوست عزیز درست شد ولی میشه نگاهش کنید اصلا استایل جالبی نداره .

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

می تونید براش استایل در نظر بگیرید.کار سختی نیست موارد مشابه در انجمن هست.می تونید برای لینک استایل در نظر بگیرید مثلا این استایل لینک شما می تونه باشه که در فایل استایل کپی و سپس در همون کد مطالب تصادفی عبارت <ul> رو به <ul class="randoms"> تغییر بدید :


.randoms a {
padding:4px;
color:#رنگ متن;
transition:all 0.3s ease-in;
-o-transition:all 0.3s ease-in;
-moz-transition:all 0.3s ease-in;
-webkit-transition:all 0.3s ease-in;
}
.randoms a:hover {
color:#رنگ متن بعد از رفتن نشانگر موس;
padding:4px;
transition:all 0.3s ease-in;
-o-transition:all 0.3s ease-in;
-moz-transition:all 0.3s ease-in;
-webkit-transition:all 0.3s ease-in;
}

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

بنده اعمال کردم ولی نشد


<div id="otherPosts">
<div class="otherPostsTitle">
<a href="#"><h2><?php _e('مطالب تصادفی','lawgostar'); ?></h2></a>
</div><!--End Other Posts Title-->
<div class="otherPostsContent">
<ul class="randoms>
<?php
global $post;
$myposts = get_posts('showposts=12&orderby=rand');
foreach($myposts as $post) :
setup_postdata($post);?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
<?php wp_reset_query(); ?>
</ul>
</div><!--End Other Posts Content-->
</div><!--End Other Posts-->

اینم سی اس اس


.randoms
a {
padding:4px;
color:#3300FF;
transition:all 0.3s ease-in;
-o-transition:all 0.3s ease-in;
-moz-transition:all 0.3s ease-in;
-webkit-transition:all 0.3s ease-in;
}
.randoms
a:hover {
color:#CC0033;
padding:4px;
transition:all 0.3s ease-in;
-o-transition:all 0.3s ease-in;
-moz-transition:all 0.3s ease-in;
-webkit-transition:all 0.3s ease-in;
}

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

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

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



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