Title: Custom Classes
Author: Justin Tadlock
Published: <strong>2012 年 2 月 6 日</strong>
Last modified: 2017 年 9 月 27 日

---

搜索插件

![](https://ps.w.org/custom-classes/assets/banner-772x250.png?rev=1737208)

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://ps.w.org/custom-classes/assets/icon-256x256.png?rev=1737208)

# Custom Classes

 作者：[Justin Tadlock](https://profiles.wordpress.org/greenshady/)

[下载](https://downloads.wordpress.org/plugin/custom-classes.1.0.0.zip)

 * [详情](https://cn.wordpress.org/plugins/custom-classes/#description)
 * [评价](https://cn.wordpress.org/plugins/custom-classes/#reviews)
 * [开发进展](https://cn.wordpress.org/plugins/custom-classes/#developers)

 [支持](https://wordpress.org/support/plugin/custom-classes/)

## 描述

The Custom Classes plugin allows you to create custom classes for posts (when `post_class()`
is called) and for the `<body>` class (when `body_class()` is called). It creates
a meta box on the edit post and edit term screens in the admin with input boxes 
for adding your custom classes.

Custom post classes are added whenever your theme calls the `post_class()` function,
which is generally whenever a post is shown. Custom body classes are added on the
single view of the post whenever your theme calls the `body_class()` function.

### Like this plugin?

Please consider helping the cause by:

 * [Making a donation](https://themehybrid.com/donate).
 * [Signing up at my site](https://themehybrid.com/club).
 * [Rating the plugin](https://wordpress.org/support/view/plugin-reviews/custom-classes?rate=5#postform).

### Professional Support

If you need professional plugin support from me, the plugin author, you can access
the support forums at [Theme Hybrid](https://themehybrid.com/board/topics), which
is a professional WordPress help/support site where I handle support for all my 
plugins and themes for a community of 75,000+ users (and growing).

### Plugin Development

If you’re a theme author, plugin author, or just a code hobbyist, you can follow
the development of this plugin on it’s [GitHub repository](https://github.com/justintadlock/custom-classes).

### Will this work with custom post types?

Certainly. This plugin works with any public post type on your site. It’s not just
limited to the “post” post type.

### It’s not working!

Most likely, this means your theme isn’t using the appropriate functions (`post_class()`
and `body_class()`). You’ll need to talk to your theme author to get them to fix
this. Or, better yet, use a correctly-coded theme from [Theme Hybrid](https://themehybrid.com/themes)!

## 屏幕截图

 * [[
 * Custom classes meta box
 * [[
 * Body class output in source code

## 常见问题

  Why was this plugin created?

I wanted a quick and easy way to add styles to my posts without having to make a
tag, create a category, or use post formats. Those solutions are great, but they’re
not ideal for every situation. By using a custom class, I have complete control 
over post styles.

  How do I use it?

A meta box named “Classes” gets added to the edit post screen in the admin. From
there, you can input a custom post and/or body class for individual posts. On the
edit/new term (category, tag, etc.) screen, a new field labeled “Body Class” is 
also available.

Of course, you actually have to style the class in your theme’s `style.css` file
for anything to actually change on the front end. This plugin just outputs the classes
for you. It’s up to you to decide how to use them.

## 评价

![](https://secure.gravatar.com/avatar/1e8a5ddfe2aa731dc342bf2f48876f3f02f5dbb1e71762d529fb6c7b32ac78d9?
s=60&d=retro&r=g)

### 󠀁[Simply great](https://wordpress.org/support/topic/simply-great-146/)󠁿

 [tastymouse](https://profiles.wordpress.org/tastymouse/) 2018 年 1 月 15 日

This is really a nice plugin. It makes any theme more flexible.

![](https://secure.gravatar.com/avatar/0f1f2b664e0ccb01f0ed6fb73a5cfe814242bfc47e1eb97837234ea1fd115897?
s=60&d=retro&r=g)

### 󠀁[Works nicely!](https://wordpress.org/support/topic/works-nicely-86/)󠁿

 [Shivanand Sharma](https://profiles.wordpress.org/varun21/) 2017 年 9 月 27 日

If all you need is to add custom classes to body on a per page / post basis, this
plugin is all you need.

![](https://secure.gravatar.com/avatar/c7c585b9d00b0b051cf80058faa515a54e4c79b0bd91239dba0199729e1f51e6?
s=60&d=retro&r=g)

### 󠀁[Perfect](https://wordpress.org/support/topic/perfect-2429/)󠁿

 [innuvo](https://profiles.wordpress.org/innuvo/) 2016 年 9 月 3 日

Just what I need – works perfectly running WP version 4.3.1 without any issues at
all. Thanks for a great solution Justin As the other reviewer, could do with an 
update to tell users it is still ok to use today.

 [ 阅读所有11条评价 ](https://wordpress.org/support/plugin/custom-classes/reviews/)

## 贡献者及开发者

「Custom Classes」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ Justin Tadlock ](https://profiles.wordpress.org/greenshady/)

「Custom Classes」插件已被翻译至 1 种本地化语言。 感谢[所有译者](https://translate.wordpress.org/projects/wp-plugins/custom-classes/contributors)
为本插件所做的贡献。

[帮助将「Custom Classes」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/custom-classes)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/custom-classes/)，查看
[SVN仓库](https://plugins.svn.wordpress.org/custom-classes/)，或通过[RSS](https://plugins.trac.wordpress.org/log/custom-classes/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/custom-classes/)。

## 更新日志

The change log is located in the `changelog.md` file in the plugin folder. You may
also [view the change log](https://github.com/justintadlock/custom-classes/blob/master/changelog.md)
online.

## 额外信息

 *  版本 **1.0.0**
 *  最后更新：**8 年前**
 *  活跃安装数量 **2,000+**
 *  WordPress 版本 ** 4.8 或更高版本 **
 *  已测试的最高版本为 **4.8.28**
 *  PHP 版本 ** 5.3 或更高版本 **
 *  语言
 * [English (US)](https://wordpress.org/plugins/custom-classes/) 和 [German](https://de.wordpress.org/plugins/custom-classes/).
 *  [翻译成简体中文](https://translate.wordpress.org/projects/wp-plugins/custom-classes)
 * 标签
 * [classes](https://cn.wordpress.org/plugins/tags/classes/)
 *  [高级视图](https://cn.wordpress.org/plugins/custom-classes/advanced/)

## 评级

 5 星（最高 5 星）。

 *  [  11 条 5 星评价     ](https://wordpress.org/support/plugin/custom-classes/reviews/?filter=5)
 *  [  0 条 4 星评价     ](https://wordpress.org/support/plugin/custom-classes/reviews/?filter=4)
 *  [  0 条 3 星评价     ](https://wordpress.org/support/plugin/custom-classes/reviews/?filter=3)
 *  [  0 条 2 星评价     ](https://wordpress.org/support/plugin/custom-classes/reviews/?filter=2)
 *  [  0 条 1 星评价     ](https://wordpress.org/support/plugin/custom-classes/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/custom-classes/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/custom-classes/reviews/)

## 贡献者

 *   [ Justin Tadlock ](https://profiles.wordpress.org/greenshady/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/custom-classes/)

## 捐助

您愿意支持这个插件的发展吗?

 [ 捐助此插件 ](https://themehybrid.com/donate)