Need help with cmb2-attached-posts?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

123 Stars 57 Forks GNU General Public License v2.0 97 Commits 29 Opened issues


Custom field for CMB2 for attaching posts to a page.

Services available


Need anything else?

Contributors list

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.


Follow the example in

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.


The example demonstrates how to modify the

query args, and allows you to toggle the thumbnails display as well as a filter search input.


You can retrieve the meta data using the following:

$attached = get_post_meta( get_the_ID(), '_attached_cmb2_attached_posts', true );

This will return an array of attached post IDs. You can loop through those post IDs like the following example:

foreach ( $attached as $attached_post ) {
    $post = get_post( $attached_post );

Once you have the post data for the post ID, you can proceed with the desired functionality relating to each attached post.


  1. Field display
    Field display`

  2. Post search
    Post search`



  • Add default column display output. Simply add
    'column' => true,
    to your field registration.


  • Add post type label next to post title when multiple post-types are specified in the query args.
  • Open attached-posts links in new window, so as not to leave the current editing window. Props Shelob9, #37, #36.


  • Combined the best bits from the CMB2 Post Search field type and this field type, so now you can search for additional posts/pages/etc to be attached. User search is not currently supported. (#7).


  • Add support for attaching Users instead of Posts/Custom Posts. Props mckernanin (#27).


  • Add loader to manage loading the most recent version of this lib.



  • Add Search Filter Boxes to Lists. Props @owenconti.


  • Add plugin support. Props @yelly.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.