此段调用代码可以用来制作碰碰运气,也可以用来调用随机日志。
这个是碰运气代码:
<?php $rand_post=get_posts('numberposts=1&orderby=rand'); foreach($rand_post as $post) : ?><a href="<?php the_permalink(); ?>">随机</a><?php endforeach; ?>
下面这个是调用随机日志代码:
<?php $rand_post = get_posts('numberposts=10&orderby=rand');foreach( $rand_post as $post ) : ?><li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li><?php endforeach; ?>
发表评论