|
1 | 1 | # Creating Your First Post Type |
2 | 2 |
|
3 | | -A step-by-step guide to creating a custom post type using Secure Custom Fields. |
| 3 | +A step-by-step guide to creating a custom post type using Secure Custom Fields (SCF). |
| 4 | + |
| 5 | +**What is a custom post type?** |
| 6 | + |
| 7 | +In WordPress, a custom post type (CPT) is a content type like posts and pages, but customized to suit your specific needs. You can use CPTs to manage products, portfolios, testimonials, events, vehicles, and more—essentially any type of structured content that needs its own menu and fields. |
4 | 8 |
|
5 | 9 | ## Prerequisites |
6 | 10 |
|
7 | | -- SCF installed and activated |
8 | | -- Administrator access to WordPress |
9 | | -- Basic understanding of WordPress concepts |
| 11 | +- SCF installed and activated |
| 12 | +- Administrator access to WordPress |
| 13 | +- Basic understanding of WordPress concepts |
| 14 | + |
| 15 | +You can learn more about WordPress basics here: |
| 16 | + |
| 17 | +- [Theme Basics](https://developer.wordpress.org/themes/basics/) |
| 18 | +- [Plugin Basics](https://developer.wordpress.org/plugins/plugin-basics/) |
| 19 | + |
| 20 | +## 1. Access the Admin Panel |
| 21 | + |
| 22 | +To begin creating your custom post type: |
| 23 | + |
| 24 | +- Go to **Secure Custom Fields → Post Types** in your WordPress admin menu. |
| 25 | +- Click the **"Add New"** button to open the creation form. |
| 26 | + |
| 27 | +## 2. Basic Configuration |
| 28 | + |
| 29 | +These fields help you define how your post type will appear and behave: |
| 30 | + |
| 31 | +### Plural Label \* |
| 32 | + |
| 33 | +This is the name that will appear in the admin sidebar. For example, `Movies`. |
| 34 | + |
| 35 | +### Singular Label \* |
| 36 | + |
| 37 | +Used for individual entries. Example: `Movie`. |
| 38 | + |
| 39 | +### Post Type Key \* |
| 40 | + |
| 41 | +A technical identifier for WordPress to recognize this post type. Use lowercase letters and underscores only. Max 20 characters. Example: `movie`. |
| 42 | + |
| 43 | +### Taxonomies |
| 44 | + |
| 45 | +Choose existing taxonomies like **category** or **tags** if you want to group or filter your content. You can also select custom ones like **Brand** or **Color**. |
| 46 | + |
| 47 | +### Public |
| 48 | + |
| 49 | +Choose **Yes** to make your post type visible on the website and admin area. Choose **No** to keep it private. |
| 50 | + |
| 51 | +### Hierarchical |
| 52 | + |
| 53 | +Set to **Yes** if you want your items to be nested (like pages). Set to **No** for a flat list (like blog posts). |
| 54 | + |
| 55 | +### Advanced Configuration |
| 56 | + |
| 57 | +Enable this to unlock more advanced options, useful when you need more control over how your post type works. |
| 58 | + |
| 59 | +## 3. Advanced Settings |
| 60 | + |
| 61 | +These options let you customize deeper behaviors and labels. |
10 | 62 |
|
11 | | -## Steps |
| 63 | +### Supports |
12 | 64 |
|
13 | | -1. **Access the Admin Panel** |
14 | | - - Navigate to Custom Fields → Post Types |
15 | | - - Click "Add New" |
| 65 | +Select which features to enable when editing a post, such as: |
16 | 66 |
|
17 | | -2. **Basic Configuration** |
18 | | - - Enter a descriptive name |
19 | | - - Configure labels |
20 | | - - Set visibility options |
| 67 | +- **Title**: Adds a title field |
| 68 | +- **Editor**: Main content box |
| 69 | +- **Featured Image**: Allow image upload |
| 70 | +- **Comments**, **Author**, **Excerpt**, etc. |
21 | 71 |
|
22 | | -3. **Advanced Settings** |
23 | | - - Configure permalinks |
24 | | - - Set up taxonomies |
25 | | - - Define capabilities |
| 72 | +### Description |
26 | 73 |
|
27 | | -4. **Testing** |
28 | | - - Save your post type |
29 | | - - Create a test post |
30 | | - - View on front end |
| 74 | +A short explanation of what this post type is about. Helpful for organization. |
| 75 | + |
| 76 | +### Active |
| 77 | + |
| 78 | +Make sure this is set to **Yes** so your post type is registered and usable. |
| 79 | + |
| 80 | +### Labels |
| 81 | + |
| 82 | +These are the texts that WordPress shows throughout the dashboard. For example: |
| 83 | + |
| 84 | +- **Menu Name**: What appears in the sidebar |
| 85 | +- **Add New Item**: Button to create a new entry |
| 86 | +- **Edit Item**, **View Item**, **Search Items**, etc. |
| 87 | + You can keep the default labels or customize them to your liking. |
| 88 | + |
| 89 | +### Visibility Options |
| 90 | + |
| 91 | +Control where your post type appears in the admin and site: |
| 92 | + |
| 93 | +- Show in dashboard menu |
| 94 | +- Show in admin bar |
| 95 | +- Show in appearance menus |
| 96 | + |
| 97 | +### Menu Icon and Position |
| 98 | + |
| 99 | +Choose an icon for your post type from the WordPress Dashicons set. Optionally, set its position in the sidebar. |
| 100 | + |
| 101 | +### Permalinks and URLs |
| 102 | + |
| 103 | +You can define how URLs will look for your post type: |
| 104 | + |
| 105 | +- **Slug**: A custom word for your URL (e.g., `/movie/`) |
| 106 | +- Enable archive and pagination |
| 107 | +- Optionally include RSS feeds |
| 108 | + |
| 109 | +### Permissions |
| 110 | + |
| 111 | +If needed, you can assign custom capabilities like `edit_movie` or `delete_movies`. Useful for advanced role control. |
| 112 | + |
| 113 | +### REST API Settings |
| 114 | + |
| 115 | +Enable this if you plan to use the post type with the block editor or external tools. |
| 116 | + |
| 117 | +- You can customize the API route, namespace, or controller class if needed. |
| 118 | + |
| 119 | +## 4. Testing |
| 120 | + |
| 121 | +Once everything is set up: |
| 122 | + |
| 123 | +- Click **Save** to register your post type. |
| 124 | +- Go to the WordPress dashboard menu where your new post type now appears. |
| 125 | +- Click **Add New** and create a test entry. |
| 126 | +- Visit your website and check that it appears correctly on the frontend. |
31 | 127 |
|
32 | 128 | ## Next Steps |
33 | 129 |
|
34 | | -- Add custom fields to your post type |
35 | | -- Configure archive displays |
36 | | -- Set up custom taxonomies |
| 130 | +- Add custom fields to your post type via Secure Custom Fields |
| 131 | +- Configure how archives and single templates are displayed in your theme |
| 132 | +- Set up or register your own taxonomies for more organization |
| 133 | + |
| 134 | +## For Developers |
| 135 | + |
| 136 | +If you're a developer and prefer to register custom post types using code instead of the admin interface, you can refer to the official WordPress documentation: |
| 137 | + |
| 138 | +[How to Create Custom Post Types with Code](https://developer.wordpress.org/plugins/post-types/) |
| 139 | + |
| 140 | +This guide includes examples and explanations on using `register_post_type()` and other related functions. |
0 commit comments