Home> CMS Tutorial> WordPress> body text

How to control the categories displayed on the homepage in WordPress

藏色散人
Release: 2021-01-14 17:17:35
forward
3681 people have browsed it

The following columnWordPress Tutorialwill introduce to you how to control the categories displayed on the homepage in WordPress. I hope it will be helpful to friends in need!

How to control the categories displayed on the homepage in WordPress

wordpressControl the categories displayed on the homepage

WordPress will display the latest articles on the homepage, you can Control the number of articles displayed in the background, but cannot control the categories to be displayed. General CMS systems can control the categories to be displayed, but sorry, WordPress is not a CMS. However, WordPress can also control the categories to be displayed. Although it cannot be set in the background, it can be achieved by modifying the template code.

One method is:

Copy after login

Put this code in the front part of the index.php file in the theme directory. (Before controlling the code to display the article)

Another method:

If it is in the category with id=5, continue the next cycle without outputting this article. This code needs to be added at the beginning of the main loop (The Loop), that is, find

Then add the above code after this sentence. In comparison, the first method is more convenient, and the second method also provides a solution.

The above is the detailed content of How to control the categories displayed on the homepage in WordPress. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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!