Latest articles, popular articles, and random articles for WordPress with no plug-ins

Source: Internet
Author: User
Although the widget sidebar tool that comes with WordPress can easily call the latest articles, popular articles, and random articles. However, using the sidebar will affect the effect of custom sidebar. Many bloggers who use wordpress use other plug-ins for calling, such as the Chinese toolbox. The following describes how to call these three types of articles without using plug-ins. Call the latest article: & lt; ul & gt ;&

Although the widget sidebar tool that comes with WordPress can easily call the latest articles, popular articles, and random articles. However, using the sidebar will affect the effect of custom sidebar. Many bloggers who use wordpress use other plug-ins for calling, such as the Chinese toolbox. The following describes how to call these three types of articles without using plug-ins.

Call the latest article:

 
 
    have_posts()) : $post_query->the_post();? ? $do_not_duplicate = $post->ID; ?>? ?
  • ? ? ? ? "> ? ?

Call popular articles:

 
 
    '',? ? ? ? 'Post _ status' => 'Publish ', // select only public articles .? ? ? ? 'Post _ not_in '=> array ($ post-> ID), // exclude the current article? ? ? ? 'Caller _ get_posts' => 1, // exclude the post with Callback .? ? ? ? 'Orderby' => 'Comment _ count', // Sort by comment .? ? ? ? 'Posts _ per_page '=> $ post_num? ? );? ? $ Query_posts = new WP_Query ();? ? $ Query_posts-> query ($ args );? ? While ($ query_posts-> have_posts ()){? ? ? ? $ Query_posts-> the_post () ;?>? ?
  • ? ? ? ? "Title =" "> ? ?

Call a random article:

 
 
    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=" ">? ? ? ? ? ? ? ? ? ? ? ?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.