网站制作带缩略图随机文章小工具
闪灵科技(开发者团队)介绍:网站设计带缩略图随机文章小工具,只需要输入你要演示的网站地址,网页会自动生成缩略图,并且各个演示设备网页还是动态效果,用来做站点主题演示及UI初级适配性再合适不过了。
1、建立文件random.PHP
<aside id=”random” class=”widget widget_recent_entries”>
<h3 class=”widget-title”>随机推荐阅读</h3>
<ul>
<?php
global $post;
$postid = $post->ID;
$args = array( ‘orderby’ => ‘rand’, ‘post__not_in’ => array($post->ID), ‘showposts’ => 15);
$query_posts = new WP_Query();
$query_posts->query($args);
?>
<?php while ($query_posts->have_posts()) : $query_posts->the_post(); ?>
<li><a href=”<?php the_permalink(); ?>” rel=”bookmark” title=”<?php the_title_attribute(); ?>”><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
</aside>
2、在functions.php添加如下代码
if( function_exists( ‘register_sidebar_widget’ ) ) {
register_sidebar_widget(‘随机文章’,’random’);
}
function lt_random() { include(TEMPLATEPATH . ‘/random.php’); }