WordPress调用最新文章 热门文章 相关文章 随机文章代码

鱼见海资源网最新教程:

wordpress程序是一个比较高效的网站制作程序,在学员学习如何做网站的时候,可以使用wp程序作为自己的首选建站程序,只要熟练的运用它的网站代码就可以制作出自己需要的网站来。

下面是学做网站论坛提供关于wordpress程序调用最新文章、热门文章、相关文章、随机文章代码,供广大学习网站制作培训课程的学员共享。

wordpress最新文章代码:

  • numberposts=10最新10篇文章
    orderby=date按日期调用

    wordpress相关文章代码:(调用同一分类)

    ID);
    if ($cats) {
    $args = array(
    'category__in' => array( $cats[0] ),
    'post__not_in' => array( $post->ID ),
    'showposts' => 6,
    'caller_get_posts' => 1
    );
    query_posts($args);
    if (have_posts()) :
    while (have_posts()) : the_post(); update_post_caches($posts); ?>
    
  • 暂无相关文章
  • 标签相关文章调用:(调用相同标签下的文章)

    ID);
    if ($post_tags) {
    foreach ($post_tags as $tag) {
    // 获取标签列表
    $tag_list[] .= $tag->term_id;
    }
    
    // 随机获取标签列表中的一个标签
    $post_tag = $tag_list[ mt_rand(0, count($tag_list) - 1) ];
    
    // 该方法使用 query_posts() 函数来调用相关文章,以下是参数列表
    $args = array(
    'tag__in' => array($post_tag),
    'category__not_in' => array(NULL), // 不包括的分类ID
    'post__not_in' => array($post->ID),
    'showposts' => 10, // 显示相关文章数量
    'caller_get_posts' => 1
    );
    query_posts($args);
    
    if (have_posts()) {
    while (have_posts()) {
    the_post(); update_post_caches($posts); ?>
    
  • *
  • * 暂无相关文章'; } wp_reset_query(); } else { echo '
  • * 暂无相关文章
  • '; } ?>

    wordpress随机文章代码:

  • numberposts=10 最新10篇文章
    orderby=date 按日期调用
    category=1 只调用某个分类目录下的文章

    文章来源于互联网

    © 版权声明
    THE END
    喜欢就支持一下吧
    点赞229 分享
    评论 抢沙发
    头像
    欢迎您留下宝贵的见解!
    提交
    头像

    昵称

    夸夸
    夸夸
    还有吗!没看够!
    取消
    昵称表情代码图片

      暂无评论内容