In website content operation, we often encounter such needs: we hope to display most of the content on the article list page, but articles of certain specific categories should not be included.For example, you may have a "Company Announcement" category that you want to display on a separate page, or some articles intended for internal reference that you do not want to appear in the regular public article list.AnQiCMS provides a very flexible and intuitive way to handle this situation, allowing you to precisely control the display of content on the frontend.

The Anqi CMS enables highly customizable content display through its powerful template tag system. When we need to display an article list on the website, we usually usearchiveListThis core tag.This label not only helps us call various article content but also provides rich parameters for filtering and sorting, including a special parameter for excluding specific categories.

To achieve the purpose of excluding specific category content from the article list, we mainly make use ofarchiveListthe tag inexcludeCategoryIdThe parameter. The function of this parameter is very direct: it tells the system to skip all articles under the specified category when generating the article list.

It is also very simple to operate.Firstly, you need to log in to the Anqi CMS backend management interface, find and enter the "Document Category" page under "Content Management.Here, you can see all the categories created and their corresponding IDs.This ID is a unique identifier for each category and is the key to our exclusion operation.5And the ID of the "Internal Materials" category is12.

Next, go back to the front-end template of your website used to display the article list. Find the code that usesarchiveListThe part of the label. Usually, this is in the template of the list page, home page, or other pages that need to aggregate display articles. In this label, you can add it like thisexcludeCategoryIdParameters:

{% archiveList archives with type="page" limit="10" excludeCategoryId="5,12" %}
    {# 列表内容的循环展示代码 #}
    {% for item in archives %}
    <li>
        <a href="{{item.Link}}">
            <h5>{{item.Title}}</h5>
            <div>{{item.Description}}</div>
        </a>
    </li>
    {% endfor %}
{% endarchiveList %}

In the above example code,excludeCategoryId="5,12"Tell the CMS, when generatingarchivesthis article list, please automatically exclude categories with ID of5and12All articles. If you only need to exclude one category, just fill in a single ID, for exampleexcludeCategoryId="5"If you need to exclude multiple categories, you can use English commas to connect these category IDs, as shown in the example.

The advantage of this method lies in its flexibility and ease of use.You do not need to modify complex logic code, just add or modify a parameter in the template tag, and you can easily achieve fine-grained control over the article list content.This is crucial for maintaining the clarity of the website content structure, ensuring that users see the most relevant and appropriate content in different areas.For example, by excluding promotional category, your regular news list can focus more on industry trends; by excluding expired event categories, your event list will always display the latest content, enhancing user experience.

In practical applications, it is recommended that you thoroughly test the template after modification to ensure that the content display meets expectations.Additionally, clearly recording the purpose and ID of each category will help with future content management and template maintenance.


Common Questions (FAQ)

1.excludeCategoryIdandcategoryIdWhat are the differences between parameters?

excludeCategoryIdThe parameter is used to "exclude" specified categories from the article list, meaning that all categories' articles are displayed except for those you explicitly specify to exclude.categoryIdThe parameter is the opposite, it is used to 'include' specified category content, that is, only to display articles under a specific category or categories you explicitly specify, and not to display articles under other categories.Both are complementary filtering methods, choose to use according to your specific needs.

2. Where can I find the category ID that needs to be excluded?

3. UseexcludeCategoryIdWill excluding content affect the website's SEO?

In most cases, usingexcludeCategoryIdParameters exclude some content in the front-end template, mainly affecting the visual experience of users on specific pages.If the excluded content can still be crawled by search engines through other pages (such as individual category pages, site maps), it will not have a negative impact on the SEO performance of this content.This parameter only controls the 'display' logic of the content in a specific list, rather than 'deleting' or 'hiding' it from the website so that it is not discovered by search engines.