Home> CMS Tutorial> WordPress> body text

How to call the latest, popular, and random articles in WordPress without plug-ins

藏色散人
Release: 2020-01-11 09:36:35
Original
2499 people have browsed it

How to call the latest, popular, and random articles in WordPress without plug-ins

#How does WordPress call the latest, popular, and random articles without plug-ins?

WordPress has no plug-in to call the latest, popular, and random article example codes

Recommended: "wordpress tutorial"

WordPress has no plug-in to call the latest, popular, and random articles. The specific implementation code is as follows. Interested friends can refer to it. I hope it will be helpful to everyone in calling news.

Call the latest Article:

The code is as follows:

    have_posts()) : $post_query->the_post(); $do_not_duplicate = $post->ID; ?>
  • ”>
Copy after login

Call popular articles:

The code is as follows:

    ”, ‘post_status’ => ‘publish’, // 只选公开的文章. ‘post__not_in’ => array($post->ID),//排除当前文章 ‘caller_get_posts’ => 1, // 排除置顶文章. ‘orderby’ => ‘comment_count’, // 依评论数排序. ‘posts_per_page’ => $post_num ); $query_posts = new WP_Query(); $query_posts->query($args); while( $query_posts->have_posts() ) { $query_posts->the_post(); ?>
  • ” title=””>
Copy after login

Call random articles:

The code is as follows :

    ID; $args = array( ‘orderby’ => ‘rand’, ‘post__not_in’ => array($post->ID), ‘showposts’ => 10); $query_posts = new WP_Query(); $query_posts->query($args); ?> have_posts()) : $query_posts->the_post(); ?>
  • ” rel=”bookmark” title=””>
Copy after login

The above is the detailed content of How to call the latest, popular, and random articles in WordPress without plug-ins. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!