×

Wordpress教程

显现WordPress随机文章(不运用插件)(wordpress调用随机文章)

星花园站长资源网 星花园站长资源网 发表于2024-06-28 浏览4201 评论0
通常我们可以通过Random Pages Widget插件来实现随机文章的显示,不过如果不想涉及插件,下面的代码也可以调用出随机文章哦。 <ul> <?php $rand_posts = get_posts('numberposts=5&orderby=rand'); foreach( $rand_posts as $post ) : ?>    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul> 来源

Wordpress教程

显现WordPress随机文章(不运用插件)(wordpress调用随机文章)

星花园站长资源网 星花园站长资源网 发表于2024-05-31 浏览3660 评论0
通常我们可以通过Random Pages Widget插件来实现随机文章的显示,不过如果不想涉及插件,下面的代码也可以调用出随机文章哦。 <ul> <?php $rand_posts = get_posts('numberposts=5&orderby=rand'); foreach( $rand_posts as $post ) : ?>    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul> 来源

Wordpress教程

wordpress调用随机文章代码(wordpress调用随机文章)

星花园站长资源网 星花园站长资源网 发表于2024-05-29 浏览4776 评论0
博主们在浏览博客时可能会注意到某些网站中的“随机文章”板块,这样不仅丰富了网站内容,也可能延长了访客在你博客上的停留时间,降低网站的跳出率,有利于SEO!笔者就分享下随机调用文章的php代码吧!<?php $rand_posts = get_posts('numberposts=10&orderby=rand'); foreach( $rand_posts as $post ) :?>