Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yCodeTech/6ad70fd79fba65434e2daedc5e4d1603 to your computer and use it in GitHub Desktop.
Save yCodeTech/6ad70fd79fba65434e2daedc5e4d1603 to your computer and use it in GitHub Desktop.
Setup WP Custom Post Types and Taxonomies

Setup WP Custom Post Types and Taxonomies

Install CPT UI.

Adding new Custom Post Types (CPT UI)

Under the CPT UI, click Add/Edit Post Types.

  1. Post Type Slug = singular lowercased name eg. product
  2. Plural Label = plural first-letter capitalised eg. Products
  3. Singlular Label = singular first-letter capitalised eg. Product
  4. Click the Auto populate label link

In the settings section...

  1. Has Archive = true with the textbox should be the plural lowercased name of the post type.
  2. With Front = false
  3. Menu Icon = whatever icon represents the post type eg. products is a shopping bag.
  4. Supports = title, editor, featured image, excerpt; all ticked.
  5. Click Add

Add a new Taxonomy

Under the CPT UI, click Add/Edit Taxonomies.

  1. Taxonomy Slug = descriptive category slug with underscores eg. product categories would be prod_cat.
  2. Plural Label = Free text of the category plural eg. Product Categories.
  3. Singular Label = Free text of the category singular eg. Product Category.
  4. Click the Auto Populate labels link.
  5. Attach to Post Type = Check the post type just created from above eg. Products.

In the settings section...

  1. Hierarchical = true
  2. Custom Rewrite Slug = lowercase plural of the post type eg. products
  3. Rewrite With Front = false
  4. Click Add
  5. Go back to the Add/Edit Post Types, and click the Edit Post Types tab, and select your newly created post type from the select box (if not already selected).
  6. Scroll all the way down to the bottom of the page, and under Taxonomies check the newly created taxonomy to associate them with the post type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment