In website content operation, we often encounter such needs: we hope to display most of the content on the article list page, but some specific category articles are not listed.For example, you may have a "Company Announcement" category that you only want to display on a separate page, or some articles for internal reference that you do not want to appear in the regular public article list.AnQiCMS (AnQiCMS) provides a very flexible and intuitive way to handle this situation, allowing you to precisely control the display of content on the front end.
AnQi CMS uses its powerful template tag system to make content display highly customizable. When we need to display a list of articles on the website, we usually usearchiveListThis is the core tag. This tag can help us call various article content, and it 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 usearchiveListin the labelexcludeCategoryIdThe parameter serves a very direct function: it tells the system to skip all articles under the specified category when generating the article list.
It is also very simple to operate. First, you need to log in to the Anqi CMS backend management interface, find and enter the "Content Management" under the "Document Classification" page.Here you can see all the categories created and their corresponding IDs.This ID is the unique identifier for each category and is the key to our exclusion operation.For example, assume that the ID of your "Company Announcement" category is5While 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 section of the tag. Usually, this is on the list page, homepage, or other page templates where articles need to be aggregated. In this tag, 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 example code above,excludeCategoryId="5,12"Tell Anqi CMS, when generatingarchivesthis article list, please automatically exclude category ID of5and12All articles. If you need to exclude only one category, you can enter 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 content of the article list.It is crucial to maintain the clarity of the website content structure, ensuring that users see the most relevant and appropriate content in different regions.For example, by excluding promotional activity categories, your regular news list can focus more on industry trends;By excluding expired activity categories, your activity list will always display the latest content, enhancing user experience.
In practice, it is recommended that you thoroughly test the template after modification to ensure that the content displayed meets expectations.At the same time, clearly recording the purpose and ID of each category will help with future content management and template maintenance.
Frequently Asked Questions (FAQ)
1.excludeCategoryIdandcategoryIdWhat is the difference between parameters?
excludeCategoryIdThe parameter is used to 'exclude' specific categories of content from the article list, that is, to display all articles of all categories, except those explicitly specified to be excluded, and thatcategoryIdThe parameter is the opposite, it is used to 'include' specified category content, that is, only to display articles under the 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?
You can find the category ID in the Anqi CMS backend management interface.After logging into the backend, navigate to the "Content Management" -> "Document Category" page.On this page, you will see a list of categories, with each category name usually displayed next to its corresponding unique numeric ID.Note down these IDs to use them in template tags.
3. UseexcludeCategoryIdWill excluding content affect the website's SEO?
In most cases, to useexcludeCategoryIdThe parameter excludes some content in the front-end template, mainly affecting the visual experience of users on specific pages.If excluded content can still be crawled by search engines through other pages (such as individual category pages, site maps), then it will not have a negative impact on the SEO performance of such content.This parameter only controls the display logic of content in a specific list, rather than deleting or hiding it from the website so that it is not discovered by search engines.