forked from Tusko/ACF-CPT-Options-Pages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.txt
130 lines (82 loc) · 3.34 KB
/
readme.txt
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
=== Plugin Name ===
Contributors: tusko-trush
Donate link: https://arsmoon.com/
Tags: Advanced Custom Fields, ACF Options, Custom Post Type, Archive
Requires at least: 3.0
Tested up to: 4.8.3
Stable tag: 1.1.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Small addon for ACF Options. Adds ACF location for each custom post type archive
== Description ==
= Usage =
The default functions of [ACF plugin](http://www.advancedcustomfields.com/ "Advanced Custom Fields") (`get_field, the_field, etc.`) can be used to load values from a CPT Options Pages, but second parameter is required to target the CPT options.
This is similar to passing through a `$post_id` parameter to target a specific post object.
The $post_id parameter needed is a string containing the `cpt_` and CPT name in the following format: `"cpt_{CPT_NAME}"`
= Examples =
>In examples Custom Post Type name is `projects`.
So, let's go!
**Display a field**
<p><?php the_field('field_name', 'cpt_projects'); ?></p>
**Retrieve a field**
<?php
$field = get_field('field_name', 'cpt_projects');
// do something with $field
?>
**Display a sub field**
`
<?php if( have_rows('repeater_name', 'cpt_projects') ): ?>
<ul>
<?php while( have_rows('repeater_name', 'cpt_projects') ): the_row(); ?>
<li><?php the_sub_field('the_title'); ?></li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
`
**Display with shortcode**
[acf field="field_name" post_id="cpt_projects"]
> Please read documentation about [shortcodes with ACF](http://www.advancedcustomfields.com/resources/shortcode/ "ACF Shortcode")
## Customization
`
function cpt_projects_customize($cptmenu) {
$cptmenu['page_title'] = 'Dev Custom title';
$cptmenu['menu_title'] = 'Dev Custom title';
return $cptmenu;
}
add_filter('cpt_projects_acf_page_args', 'cpt_projects_customize');
`
Don't forget to replace `cpt_projects_` to your custom post type name :)
= License =
Copyright (c) 2017, [Tusko Trush](https://frontend.im/?github "Front-End Developer")
= Requirements =
You must buy ACF PRO or ACF Options Page Addon.
= Translation =
**qTanslate-X**
If you are using Qtranslate-X, you must install [ACF Qtranslate](https://uk.wordpress.org/plugins/acf-qtranslate/ "ACF Qtranslate").
**WPML/Polylang**
If you are using WPML or Polylang, you must add constant `ICL_LANGUAGE_CODE` to `post_id`,
for example: `get_field('archive_title', 'cpt_projects_' . ICL_LANGUAGE_CODE)`.
== Installation ==
1. Upload 'acf-cpt-options-pages' to the '/wp-content/plugins/' directory.
2. Activate the plugin through the 'Plugins' menu in WordPress.
3. Create your Custom Field Group, set location rule 'Options Page' and choose your 'Custom Post Type'
4. Read the documentation to display your data.
== Frequently Asked Questions ==
If you have any questions on this please post an issue/question at [Github Issues](https://github.com/Tusko/ACF-CPT-Options-Pages/issues)
== Screenshots ==
1. assets/screenshot-1.png
== Changelog ==
= 1.1.0 =
* Support MO translations
* Customization using `add_filter`
= 1.1.0 =
* WPML and Polylang compatibility added.
= 1.0.2 =
* Update documentation.
* Change labels and slugs.
= 1.0.1 =
* Plugin created.
== Upgrade Notice ==
= 1.0.2 =
* Update documentation.
* Change labels and slugs.