傻大憨

wordpress调用随机文章和随机推荐文章

wordpress调用随机文章的代码如下:

<?php
$query = array(
'post_type' => 'post',
'orderby' => 'rand'
);
$posts = new WP_Query( $query );
if ( $posts->have_posts() ) {
while( $posts->have_posts() ) :
$posts->the_post();
the_content();
endwhile;
}
wp_reset_query();
?>

wordpress随机调用置顶推荐的文章代码:

<?php
//获取置顶文章的ID串
$rand_id = get_option( 'sticky_posts' );
$query = array(
'post__in' => $rand_id,
'post_type' => 'post',
'orderyby' => 'rand',
'numberposts' => 2
);
$posts = new WP_Query( $query );
if ( $posts->have_posts() ) {
while( $posts->have_posts() ) :
$posts->the_post();
the_content();
endwhile;
}
wp_reset_query();
?>
Published
Categorized as 建站知识 Tagged ,

By 傻大憨

shadahan.com是一个关注跨境电商、创业话题的网站。

如何在WordPress中通过post文章ID获取分类名称

这是个简单的方法,在WordPress中列出一篇文章的所属类别名称。通过以下这段代码就可以实现。

获取wordpress某个栏目的内容数量

在制作wordpress模板时,有时会需要调用某个分类目录下的所有内容数量,通过这段简洁的代码就可以实现。

Jianzhanpress themes are the best Chinese WordPress themes to use

Jianzhanpress.com themes are the best Chinese WordPress themes to use

wordpress回收站功能增强

只需要两步就可以让wordpress加收站功能变得更强。

WordPress外贸建站成为建站专家的捷径

  WordPress外贸建站教程是学习如何建立和管理网站的理想起点。对于零基础者,选择一个高效的学习路径将帮… Continue reading WordPress外贸建站成为建站专家的捷径

WordPress外贸建站课零基础也能轻松入门秘诀

  在数字化时代,拥有一门WordPress建站技能是在外贸领域站稳脚跟的关键之一。对于零基础的学员而言,选择… Continue reading WordPress外贸建站课零基础也能轻松入门秘诀