forked from vinkla/extended-acf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
with-extended-cpts.php
49 lines (43 loc) · 1.2 KB
/
with-extended-cpts.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
<?php
// This example is using the Extended CPTs package to register custom post types
// and taxanomies. Please see the repository for more information:
// https://github.com/johnbillion/extended-cpts
use WordPlate\Acf\Fields\Wysiwyg;
use WordPlate\Acf\Location;
register_extended_post_type('faq', [
'menu_icon' => 'dashicons-format-chat',
'has_archive' => false,
'supports' => ['title', 'revisions'],
'admin_cols' => [
'category' => [
'taxonomy' => 'topic',
],
],
'taxonomies' => ['topic'],
], [
'singluar' => 'FAQ',
'plural' => 'FAQ',
'slug' => 'faq',
]);
register_extended_taxonomy('topic', 'faq', [
'hierarchical' => false,
'meta_box' => 'radio',
'required' => true,
'hierarchical' => false,
'show_in_rest' => true,
]);
// In this example we use the title as the question.
register_extended_field_group([
'title' => 'FAQ',
'fields' => [
Wysiwyg::make('Answer')
->instructions('Add the question answer.')
->mediaUpload(false)
->toolbar('faq')
->tabs('visual')
->required(),
],
'location' => [
Location::if('post_type', 'faq'),
],
]);