Skip to content

Commit 0a7ba7a

Browse files
committed
Updates the documentation: Adds tutorials on creating post types, custom fields, taxonomies, and options pages, and improves guidance on the relationship between post types, taxonomies, and custom fields.
1 parent 3af11e8 commit 0a7ba7a

File tree

6 files changed

+617
-23
lines changed

6 files changed

+617
-23
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Creating Your First Custom Field
2+
3+
A beginner-friendly guide to adding custom fields using Secure Custom Fields (SCF).
4+
5+
**What is a custom field?**
6+
7+
Custom fields let you add structured data to your content. With SCF, you can attach fields like text inputs, selects, image uploads, and more to your posts, pages, or custom post types.
8+
9+
## Prerequisites
10+
11+
- SCF installed and activated
12+
- A post type (default or custom) where you'll attach your fields
13+
- Administrator access to WordPress
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+
- Go to **Secure Custom Fields → Field Groups** in your WordPress admin menu.
23+
- Click **"Add New"** to create a new group of fields.
24+
25+
## 2. Basic Configuration
26+
27+
#### Field Group Title
28+
29+
Give your field group a descriptive name, like `Movie Details` or `Product Specs`.
30+
31+
#### Location Rules
32+
33+
Choose where this group should appear. For example:
34+
35+
- Post type is equal to `Movie`
36+
- Page template is `Product Page`
37+
38+
This ensures your fields appear only where you need them.
39+
40+
#### Active
41+
42+
Make sure the field group is set to **Active** so it appears in the editor.
43+
44+
## 3. Adding Fields
45+
46+
Click **"Add Field"** to create your first field. For each field, configure:
47+
48+
- **Label**: The visible name of the field (e.g., `Director`)
49+
- **Field Name**: A unique identifier used in code (e.g., `director`)
50+
- **Field Type**: Choose from text, textarea, number, image, checkbox, select, and more
51+
- **Instructions**: Optional helper text to guide users
52+
- **Required**: Whether this field must be filled in
53+
- **Default Value** and **Placeholder**: Optional presets
54+
55+
Repeat this process for as many fields as needed.
56+
57+
## 4. Testing
58+
59+
- Go to a post of the type you've targeted with the field group.
60+
- You should now see your custom fields below the content editor.
61+
- Fill in test data and save the post.
62+
- Confirm the fields save and appear as expected.
63+
64+
## Next Steps
65+
66+
- Display the custom field values on the frontend using SCF template functions
67+
- Use conditional logic or field groups to organize complex forms
68+
- Combine with taxonomies or other field groups for richer structures
69+
70+
## For Developers
71+
72+
While Secure Custom Fields makes it easier to manage and display custom fields with a user-friendly interface, WordPress also includes native support for custom fields that can be managed programmatically using functions like `get_post_meta()` and `add_post_meta()`.
73+
74+
You can learn more about WordPress native custom fields here:
75+
76+
👉 [WordPress Native Custom Fields](https://developer.wordpress.org/plugins/metadata/custom-fields/)
77+
78+
To access custom field values in your theme or plugin, use SCF functions you can learn more about SCF’s developer API in their official documentation.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Creating Your First Options Page
2+
3+
A step-by-step guide to building a global settings page using Secure Custom Fields (SCF).
4+
5+
**What is an options page?**
6+
7+
An options page is a custom admin screen where you can store site-wide settings that are not linked to individual posts, pages, or taxonomies. These values are useful for things like contact details, configuration values, or custom messages that may appear across your theme.
8+
9+
## Prerequisites
10+
11+
- SCF (Secure Custom Fields) installed and activated
12+
- Administrator access to WordPress
13+
- Basic understanding of WordPress admin and SCF interface
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+
- Go to **Secure Custom Fields → Options Pages** in your WordPress admin sidebar.
23+
- Click **"Add New"** to create your options page.
24+
25+
## 2. Basic Configuration
26+
27+
Set up the following fields to define the behavior and placement of your options page:
28+
29+
### Basic Settings Panel
30+
31+
- **Page Title**: The title displayed at the top of the options page (e.g., `Site Settings`).
32+
- **Menu Slug**: A unique identifier for the page URL (e.g., `site-settings`).
33+
- **Parent Page**: Choose `No Parent` to create a standalone page or select a parent if it should appear as a submenu item.
34+
- **Advanced Configuration**: Enable to access additional options.
35+
36+
### Advanced Settings Panel
37+
38+
#### Visibility
39+
40+
- **Menu Title**: Label that appears in the WordPress admin menu.
41+
- **Menu Icon**: Choose an icon from Dashicons or upload a custom SVG or URL.
42+
- **Menu Position**: Controls the position of the item in the admin sidebar.
43+
- **Redirect to Child Page**: If enabled, this page redirects to its first child page automatically.
44+
45+
#### Description
46+
47+
- **Description**: A short description to help explain the purpose of this options page.
48+
49+
#### Labels
50+
51+
- **Update Button Label**: Text shown on the submit button (e.g., `Update Settings`).
52+
- **Updated Message**: Message displayed after saving the options.
53+
54+
#### Permissions
55+
56+
- **Capability**: Required capability to view/edit this page (default is `edit_posts`).
57+
58+
#### Data Storage
59+
60+
- **Storage Location**: Choose whether to store the data in the options table (default) or bind it to a specific post, user, or term.
61+
- **Custom Storage**: Use a specific post ID (e.g., `123`) or context string (e.g., `user_1`).
62+
- **Autoload Options**: Enable to automatically load these values when WordPress initializes — useful for performance.
63+
64+
Click **Save** to create the options page. Once saved, you can start adding custom fields as needed.
65+
66+
## 3. Adding Fields
67+
68+
Add fields just like you would for any post type or taxonomy.
69+
70+
### Common Fields to Add:
71+
72+
- `company_name` — Company name (text)
73+
- `support_email` — Support contact email (email)
74+
- `emergency_alert_message` — Site-wide notice (textarea)
75+
- `global_logo` — Logo image (image upload)
76+
77+
Each of these fields will be accessible from any page or template.
78+
79+
## Next Steps
80+
81+
- Use options fields to manage design elements like footer text or banners
82+
- Reference options globally to reduce repeated settings in CPTs or pages
83+
- Combine with conditional logic to enable dynamic site-wide behavior
84+
85+
## For Developers
86+
87+
Options pages provide a clean way to centralize configuration. In more advanced implementations, you can:
88+
89+
- Register multiple options pages for different sections (e.g., Branding, API Keys)
90+
- Use `get_option()` if working outside the SCF context
91+
- Integrate with theme customizers or other plugin logic
92+
93+
Secure Custom Fields simplifies this process, but WordPress also offers a native way to register and manage options pages through the **Settings API**. This allows full control over settings registration, sanitization, and display via code.
94+
95+
👉 Learn more about the WordPress Settings API:
96+
[https://developer.wordpress.org/plugins/settings/settings-api/](https://developer.wordpress.org/plugins/settings/settings-api/)

docs/tutorials/first-post-type.md

Lines changed: 127 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,140 @@
11
# Creating Your First Post Type
22

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.
48

59
## Prerequisites
610

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.
1062

11-
## Steps
63+
### Supports
1264

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:
1666

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.
2171

22-
3. **Advanced Settings**
23-
- Configure permalinks
24-
- Set up taxonomies
25-
- Define capabilities
72+
### Description
2673

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.
31127

32128
## Next Steps
33129

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

Comments
 (0)