Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the function query posts in wordpress

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how to use the function query posts in wordpress. I hope you will gain a lot after reading this article. Let's discuss it together.

How to use the function query posts in wordpress?

Query posts is a very useful function for calling articles, which can display a variety of articles with a specific range on the same page, such as a list of articles with different ranges, such as categories, tags, dates and authors. These article lists can greatly enrich the content of wordpress pages and benefit SEO. Second-hand scientists have sorted out the functions of the article called by query posts, which are explained below.

The first is the general way of writing query posts. Usually, you define the query, then add the article loop code, and then reset the query.

The code is as follows:

Series to display related article information->

All the functions below are based on the above framework, just enter the corresponding parameters in query_posts (); to show the scope of the article you want.

1. Category Parameters (article classification parameters)

Cat-enter the category number to display the articles in that category

Category_name-enter a category name to display the articles within that category

Category__and-displays articles that are included in multiple categories at the same time (limited to entering classification numbers to identify)

Category__in-displays articles in this category, but does not include articles in the subcategory (limited to entering category numbers to identify)

Category__not_in-articles in other categories and sub-categories are displayed except for articles in a certain category (limited to entering classification numbers to identify)

The code is as follows:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report