CMB2 / cmb2-attached-posts

Custom field for CMB2 for attaching posts to a page.
GNU General Public License v2.0
135 stars 62 forks source link

Search button does not load just custom post type posts #63

Open aeboi80 opened 4 years ago

aeboi80 commented 4 years ago

I have a custom post type called billco-products and I have registered an attached posts field

$product_properties->add_field( array(
    'name'          => __( 'Related Products', 'o2dcaframework' ),
    'desc'          => __( 'Drag products from the left column to the right column to relate them to this product.<br />You may rearrange the order of the products in the right column by dragging and dropping.', 'o2dcaframework' ),
    'id'            => $prefix . 'related_products',
    'type'          => 'custom_attached_posts',
    'column'        => true,
    'options'       => array(
        'show_thumbnails'   => true,
        'filter_boxes'      => true,
        'query_args'        => array(
            'posts_per_page'    => 10,
            'post_type'         => array('billco-products'),
        ),
    ),
) );

When you click the the search button it pulls up the modal but doesn't list any posts. If I alter the post_type args array to be

'post_type'         => array('billco-products','page'),

and then go back and click the search button, I am returned with a list of all pages as well as all of the billco-products posts.

I am not sure where the disconnect is here. Honestly it would be great to even just hide the search box since the filter box is available.

tw2113 commented 4 years ago

I guess my question is how big of a deal is this, in the event it's not necessarily a bug.

I'm getting lost the moment I'm hitting app.SearchView = window.Backbone.View.extend in our JS file, cause a types property is coming from that and I can't trace my way beyond that.

Regarding the search, you could probably add some quick styles to admin_head and hide with .cmb2-attached-posts-search-button class.