Title: Primary Categories
Author: Jacob McKinney
Published: <strong>2016 年 5 月 17 日</strong>
Last modified: 2018 年 8 月 5 日

---

搜索插件

![](https://ps.w.org/primary-categories/assets/banner-772x250.png?rev=1419117)

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

![](https://ps.w.org/primary-categories/assets/icon-128x128.png?rev=1419117)

# Primary Categories

 作者：[Jacob McKinney](https://profiles.wordpress.org/jacobmc/)

[下载](https://downloads.wordpress.org/plugin/primary-categories.zip)

 * [详情](https://cn.wordpress.org/plugins/primary-categories/#description)
 * [评价](https://cn.wordpress.org/plugins/primary-categories/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/primary-categories/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/primary-categories/#developers)

 [支持](https://wordpress.org/support/plugin/primary-categories/)

## 描述

WordPress plugin for setting and displaying primary categories for posts and custom
post types*.

This plugin creates a meta box on the post edit screen titled “Primary Category”
containing a drop down menu populated with all categories associated with that post**.
Selecting a primary category and updating the post saves this data into a custom
field with a meta key of “primary-category”.

To display a list of all posts with a particular primary category, use the shortcode[
primary-category name=”cat_name”] where cat_name is the name of the primary category
you wish to display. If a name is not specified, the shortcode will default to all
posts with “uncategorized” set as the primary category.

*Note: Custom post types must support both categories and custom fields.

**Note: As new categories are added to a post, the post must be updated before those
new categories will be available for selection as a primary category.

## 屏幕截图

 * [[
 * Example of post edit screen with primary category meta box.
 * [[
 * Example of shortcode being used in page.
 * [[
 * Example output of shortcode.

## 安装

This section describes how to install the plugin and get it working.

 1. Upload the ‘primary-categories’ directory to your ‘/wp-content/plugins/’ directory,
    or install the plugin through the WordPress plugins screen directly
 2. Activate the plugin through the ‘Plugins’ screen in WordPress
 3. Select the primary category for each post via the post edit screen
 4. Place shortcode to the content of any post type or access the data via the post
    meta key ‘primary-category’

## 常见问题

  How can I access the primary category data?

A post’s primary category is stored in the post meta under the key ‘primary-category’.

  What shortcode can I use to display posts with a particular primary category?

[primary-category name=””]

*Note: Name should reference the primary category that is to be displayed, if no
name is specified, the name parameter defaults to ‘uncategorized’.

  Why isn’t the category I added available as a primary category?

Users must update a post after adding a new category before that category will be
available as a primary category.

## 评价

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

### 󠀁[Well structured code, works as expected](https://wordpress.org/support/topic/well-structured-code-works-as-expected/)󠁿

 [jgangso](https://profiles.wordpress.org/jgangso/) 2017 年 6 月 29 日

The plugin does just what it says. The code is well-structured and seems very lightweight.
What would make it 5 stars were: – possibility to control which post types the plugin
applies to by filter – localization – (perhaps out-of-scope) allow developers to
control which taxonomy is used on each post type by filter (custom post types often
have custom taxonomies as well)

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

### 󠀁[Works fine,thanks](https://wordpress.org/support/topic/works-finethanks-2/)󠁿

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

Thanks Jacob for this plugin, works fine and is very usefull.Keep update when need
it because it,s a necesary plugin. Five Stars, thanks.

 [ 阅读所有2条评价 ](https://wordpress.org/support/plugin/primary-categories/reviews/)

## 贡献者及开发者

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

贡献者

 *   [ Jacob McKinney ](https://profiles.wordpress.org/jacobmc/)

[帮助将「Primary Categories」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/primary-categories)

### 对开发感兴趣吗?

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

## 更新日志

#### 1.0.0

Initial Commit

## 额外信息

 *  版本 **1.0.0**
 *  最后更新：**8 年前**
 *  活跃安装数量 **20+**
 *  WordPress 版本 ** 3.4 或更高版本 **
 *  已测试的最高版本为 **4.9.29**
 *  语言
 * [English (US)](https://wordpress.org/plugins/primary-categories/)
 * 标签
 * [categories](https://cn.wordpress.org/plugins/tags/categories/)[shortcodes](https://cn.wordpress.org/plugins/tags/shortcodes/)
 *  [高级视图](https://cn.wordpress.org/plugins/primary-categories/advanced/)

## 评级

 4.5 星（最高 5 星）。

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

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

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

## 贡献者

 *   [ Jacob McKinney ](https://profiles.wordpress.org/jacobmc/)

## 支持

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

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