CMB2 Field Type: Attached Posts
Custom field for CMB2 for attaching posts to a page.
by WebDevStudios · github.com/webdevstudios/cmb2-attached-posts · website
★ 134stars
66kcomposer installs
59forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/webdevstudios/cmb2-attached-posts/archive/refs/heads/master.zipAlso on Packagist as webdevstudios/cmb2-attached-posts:
composer require webdevstudios/cmb2-attached-postsFrom the readme
CMB2 Attached Posts Field
Custom field for CMB2.
The post IDs are saved in an array, which can be rearranged by dragging and dropping posts in the attached posts column. Now incorporates the same search field as the CMB2 Post Search field.
Installation
Follow the example in example-field-setup.php for a demonstration. The example assumes you have both CMB2 and this extension in your mu-plugins directory. If you're using CMB2 installed as a plugin, remove lines 6-9 of the example.
Customization
The example demonstrates how to modify the getposts query args, and allows you to toggle the thumbnails display as well as a filter search input.
Usage
You can retrieve the meta data using the following:
This will return an array of attached post IDs. You can loop through those post IDs like the following example:
Once you have the post data for the post ID, you can proceed with the desired functionality relating to each attached post.
Screenshots
1. Field display
1. Post search
Changelog
1.2.7
Add default column display output. Simply add 'column' = true, to your field registration.
1.2.6
Add post type label next to post title when multiple post-types are specified in the
Read the full README on GitHub →