Skip to content

Commit

Permalink
update readme and example again
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsternberg committed May 31, 2015
1 parent b4b8a55 commit 7e1293c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ If the ability to search for a post and attach it is more in line with what you

## 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 [line 6 of the example](https://github.com/WebDevStudios/cmb2-attached-posts/blob/master/example-field-setup.php#L6).
Follow the example in [`example-field-setup.php`](https://github.com/WebDevStudios/cmb2-attached-posts/blob/master/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](https://github.com/WebDevStudios/cmb2-attached-posts/blob/master/example-field-setup.php#L6-L9).

## Customization
In the example file `example-field-setup.php`, the field is added using the prefix `_attached_cmb2_` and the name `attached_posts` which results in a meta key of `_attached_cmb2_attached_posts`. The example also demonstrates how to modify the `get_posts` query args.
The example demonstrates how to modify the `get_posts` 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:
Expand Down
5 changes: 1 addition & 4 deletions example-field-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
*/
function cmb2_attached_posts_field_metaboxes_example() {

// Start with an underscore to hide fields from custom fields list
$prefix = '_attached_cmb2_';

$example_meta = new_cmb2_box( array(
'id' => 'cmb2_attached_posts_field',
'title' => __( 'Attached Posts', 'cmb2' ),
Expand All @@ -35,7 +32,7 @@ function cmb2_attached_posts_field_metaboxes_example() {
$example_meta->add_field( array(
'name' => __( 'Attached Posts', 'cmb2' ),
'desc' => __( 'Drag posts from the left column to the right column to attach them to this page.<br />You may rearrange the order of the posts in the right column by dragging and dropping.', 'cmb2' ),
'id' => $prefix . 'attached_posts',
'id' => 'attached_cmb2_attached_posts',
'type' => 'custom_attached_posts',
'options' => array(
'show_thumbnails' => true, // Show thumbnails on the left
Expand Down

0 comments on commit 7e1293c

Please sign in to comment.