
內容簡介
總結:這款WordPress外掛讓你可以在特定頁面、文章或自訂文章類型上新增自定義CSS類別,而無需編輯主題文件。同時還能安全地將自定義<body>類別添加至任何頁面、文章、自訂文章類型或WooCommerce視圖(商店、購物車、結帳、我的帳戶)而不需要進行任何主題編輯。
### 問題與答案
1. 有哪些重點功能可以利用這款外掛實現?
- 可以向單個頁面、部落格(文章)頁面、所有單獨文章、自訂文章類別存檔、所有自訂文章單獨存檔或特定自訂文章項目添加類別。
- 安全的自動前綴(ccaop_)可防止衝突。
- 具備WooCommerce意識:支持商店(產品存檔)、購物車、結帳和我的帳戶。
- 乾淨的管理用戶界面,列出了您創建的每個規則(類別+位置)和刪除操作。
- 啟用後重定向:啟動後,您將直接前往設置頁面。
- 輕量級:僅使用body_class過濾器,沒有前端冗餘。
2. 使用這款外掛可以如何配置自定義類別?
- 進入儀表板 → 類選項。
- 輸入自定義類別名稱(自動保存為ccaop_ {your_class})。
- 選擇應用位置:頁面/文章/自定義文章。
- 對於頁面→選擇任何頁面(這裡故意排除了部落格/文章頁面;請使用文章→部落格頁面)。
- 對於文章→選擇博客頁面(文章索引)或所有單獨文章。
- 對於自訂文章→選擇自訂文章類別和目標(存檔、所有單獨、或特定項目)。
- 點擊保存。訪問所選視圖並檢查<body> - 您將會看到您的類別。
3. 這款外掛的特點有哪些?
- 无需编写代码即可使用。
- 自動前缀的类别以避免冲突。
- 页面/帖子/自定义文章类型(存档、单个、特定项目)目标。
- WooCommerce商店、购物车、结帐、我的帐户支持。
- 规则列表,带有删除操作。
- 轻量级和快速,与主题无关。
- 适用于缓存站点(没有动态输出缓冲)。
外掛標籤
開發者團隊
原文外掛簡介
Add your own CSS classes to specific Pages, Posts, or Custom Post Types—without editing theme files.
Add custom
I created Custom Class Add On Page as a simple way to manage classes with a safe ccaop_ prefix. Choose the target (Page, Blog page, Single Post, CPT archive/single, or a specific CPT item), save, and the class is injected via the body_class filter. Clean code, lightweight implementation, and solving real problems are the focus. Collaboration and feedback are welcome.
Highlights
– Add classes to: a single Page, the Blog (Posts) page, all Single Posts, CPT Archive, all CPT Singles, or a specific CPT item.
– Safe auto-prefix (ccaop_) prevents conflicts.
– WooCommerce-aware: Shop (product archive), Cart, Checkout, and My Account are supported.
– Clean admin UI with a table listing every rule you’ve created (class + location) and a delete action.
– Activation redirect: after activation, you’re taken straight to the settings page.
– Lightweight: uses the body_class filter only—no front-end bloat.
Need Help?
About Author
Video Tutorial
⚡ What you can configure
Enter a custom class name (auto-saved as ccaop_{your_class}).
Choose where to apply it: Page / Post / Custom Post.
For Page → pick any page (Blog/Posts page is intentionally excluded here; use Post → Blog page).
For Post → choose Blog page (posts index) or All single posts.
For Custom Post → choose the CPT and target (Archive, All single, or Specific item).
Usage
Go to Dashboard → Class Option.
Type your class name (e.g. hero, saves as ccaop_hero).
Select Page / Post / Custom Post, then pick the exact target.
Click Save. Visit the selected view and inspect
⚡ Features
Ready to use—no coding needed
Auto-prefixed classes to avoid collisions
Page / Post / CPT (archive, single, specific item) targets
WooCommerce Shop, Cart, Checkout, My Account support
Rule list with delete action
Lightweight & fast, theme-agnostic
Works with cached sites (no dynamic output buffering)
WooCommerce Notes
If you select the Shop page under Page, the plugin detects it as the product archive and adds your class on Shop views correctly.
Similarly, Cart, Checkout (including endpoints like order-pay, order-received) and My Account are handled.
