-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.php
56 lines (47 loc) · 1.37 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
require 'vendor/autoload.php';
use Layered\Wp\CustomPostType;
if (!function_exists('add_action')) {
die('This file needs to be included in a WordPress plugin or theme');
}
add_action('init', function() {
// Add a custom post type
CustomPostType::add('idea', [
'labels' => [
'name' => __('Ideas', 'my-theme-or-plugin')
],
'rewrite' => [
'slug' => 'my-ideas'
],
'supports' => ['title', 'editor', 'thumbnail', 'excerpt', 'author']
])
->addTaxonomy('tag')
;
// Add Recipes - uses Custom Post Type & Meta Fields
CustomPostType::add('recipe')
->addTaxonomy('difficulty')
->addMetaFields([
'servings' => [
'name' => __('Servings', 'my-theme-or-plugin'),
'placeholder' => __('Ex: 1 cake, 2 servings, 5 cupcakes', 'my-theme-or-plugin')
],
'ingredients' => [
'name' => __('Ingredients', 'my-theme-or-plugin'),
'placeholder' => __('Ex: 200g quinoa, 2 tbsp olive oil', 'my-theme-or-plugin'),
'single' => false
],
'methods' => [
'name' => __('Methods', 'my-theme-or-plugin'),
'placeholder' => __('Ex: mix & stir the ingredients', 'my-theme-or-plugin'),
'single' => false
],
'time' => [
'type' => 'number',
'name' => __('Prep time', 'my-theme-or-plugin'),
'placeholder' => __('Ex: 15', 'my-theme-or-plugin'),
'suffix' => 'minutes',
'show_in_columns' => true
]
])
;
});