• Downloading from our site will require you to have a paid membership. Upgrade to a Premium Membership from 10$ a month today!

    Dont forget read our Rules! Also anyone caught Sharing this content will be banned. By using this site you are agreeing to our rules so read them. Saying I did not know is simply not an excuse! You have been warned.

Thảo luận Hiển thị bài viết ngẫu nhiên có thumbnail không cần plugin trong Wordpress

Kidblood

New Member
Chèn đoạn code sau vào nơi bạn muốn hiển thị.

Code:
<?php $navi_query = new WP_Query('posts_per_page=5&orderby=rand'); ?>
<?php while ($navi_query->have_posts()) : $navi_query->the_post(); ?>
<div class="thumbnail-post"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(array(40,40), array ('class' => 'alignleft')); ?></a>
<a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<div class="clear"></div>
 
<?php endwhile; wp_reset_postdata(); ?>

Chèn đoạn code sau vào css
Code:
/*Thumbnail Posts*/
.thumbnail-post {
    background: none;
    height: 73px;
    overflow: hidden;
    padding:3px;
    position: relative;
    width: 280px;
}
.thumbnail-post a {float: none;}
.thumbnail-post img {
    float: left;
    width: 60px;
    height: 60px;
    padding: 3px;
    border: 1px solid #ddd;
    margin: 2px 2px 0 0;
    padding-bottom: 3px;
    display:inline;
}
.thumbnail  .clear {clear: both;}

Chỉnh sửa lại cho phù hợp nhé.
Chúc các bạn thành công.
 

Facebook Comments

Similar threads

New posts New threads New resources

Back
Top