powerbuoy / sleek-post-types
Create post types by creating classes in /post-types/.
Installs: 2 260
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- powerbuoy/sleek-acf: ^2.0.0
- powerbuoy/sleek-modules: ^7.0.0
- powerbuoy/sleek-utils: ^1.0.0
- dev-master
- v7.0.0
- v6.7.1
- v6.7.0
- v6.6.3
- v6.6.2
- v6.6.1
- v6.6.0
- v6.5.0
- v6.4.4
- v6.4.3
- v6.4.2
- v6.4.1
- v6.4.0
- v6.3.0
- v6.2.5
- v6.2.4
- v6.2.3
- v6.2.2
- v6.2.1
- v6.2.0
- v6.1.0
- v6.0.1
- v6.0.0
- v5.3.4
- v5.3.3
- v5.3.2
- v5.3.1
- v5.3.0
- v5.2.0
- v5.1.0
- v5.0.0
- v4.0.0
- v3.2.0
- v3.1.0
- v3.0.0
- v2.0.0
- v1.1.0
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v0.0.1
- v0.0.0
This package is auto-updated.
Last update: 2025-01-26 10:46:14 UTC
README
BREAKING! v7 - exclude_from_search no longer set to false by default - sleek/post_types/archive_fields filter now gets passed the post type object - not just its name - as its second argument
Create post types by creating classes in /post-types/
.
Theme Support
N/A
Hooks
sleek/post_types/field_group
Filter the ACF field group for post types before they're added.
sleek/post_types/fields
Filter the ACF fields for post types before they're added.
sleek/post_types/archive_fields
Filter the ACF fields for the archive settings before they're added.
Functions
Sleek\PostTypes\get_file_meta()
Return information about all files in /post-types/
(internal use).
Classes
Sleek\PostTypes\PostType
Extend this class to create a post type.
PostType::init()
This method is called once on every page load. It allows you to add hooks or do whatever you like related to your post type.
PostType::config()
Return an array of post type configuration here. The array is passed directly to register_post_type. A few additional properties are available:
taxonomies
This is a native WordPress property but unlike when calling register_post_type()
any taxonomy set in here will be automatically created if it doesn't already exist.
has_single
Set this to false to disable single pages for the post type.
hide_from_search
Hides the post type from search without the side effects of the built-in exclude_from_search
.
has_settings
Set this to false to not add a "Settings" page for the post type.
has_archive
If this is false the settings page will be empty, if not it will have a "Title", "Image" and "Description".
PostType::fields()
Return an array of ACF fields from here and they will be added to the post type.
PostType::sticky_modules()
Return an array of module names and they will be added to the post type. Render a sticky module using Sleek\Modules\render('name-of-module')
.
PostType::flexible_modules()
Return an array of module names and they will be available in a flexible content field named flexible_modules
. An associative array can be used to create multiple flexible content fields;
[
'left_column' => ['text-block', 'text-blocks'],
'right_column' => ['related-posts', 'recent-comments']
]
Render a flexible module field using Sleek\Modules\render_flexible('flexible_modules')
or Sleek\Modules\render_flexible('left_column')
etc.
PostType::sticky_archive_modules()
Return an array of module names and they will be added to the post type's settings page. Render a sticky module using Sleek\Modules\render('name-of-module', 'mycpt_settings')
.
PostType::flexible_archive_modules()
Return an array of module names and they will be available in a flexible content field named flexible_modules
on the post type's settings page. An associative array can be used here too.
Render modules on the settings page using Sleek\Modules\render_flexible('flexible_modules', 'mycpt_settings')
.