New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search data append wrong #35

Open
thinhbg59 opened this Issue Jan 24, 2017 · 5 comments

Comments

Projects
None yet
5 participants
@thinhbg59

thinhbg59 commented Jan 24, 2017

Hi Team,
Thank you for your plugin.
I have one issue:
I using two field with type: custom_attached_posts
When I click the search button and select the data, I see the value returned is showing the wrong position. You can see a screenshot I attached below.
http://prntscr.com/dziula
Thanks

@jtsternberg

This comment has been minimized.

Member

jtsternberg commented Jan 24, 2017

Yah, unfortunately the feature wasn't intended to work with more than one attached-posts field on the page. Definitely a bug. Will have to update when I get a chance.

@jtsternberg jtsternberg added the bug label Jan 24, 2017

@thinhbg59

This comment has been minimized.

thinhbg59 commented Jan 24, 2017

Thanks for response very quickly. I'll wait until it gets updated.

@DizzyBHigh

This comment has been minimized.

DizzyBHigh commented Mar 17, 2017

Any News on this? am having the same issue with 2 attached post fields for adding content.
Only happens when the search button on the first field is used, it adds it to the second field. is there anyway to increase the number of entries displayed inn a list to avoid the search completely?

@technotarek

This comment has been minimized.

technotarek commented Jul 6, 2017

The problem, as described above, resides only in the Search feature. With that in mind, there is a workaround. Set the Custom Attached Post field's query args 'post_per_page' parameter to -1, which will remove the limit on the number of posts in the initial Available Posts frame. That is, every single post from your site will appear in the initial window, so you never have to use the Search component.

Beware! This may be problematic depending on the size of your site and your server or browser. If you have thousands of posts, this could cripple your database server or the WordPress UI in your browser. You can help prevent against this by using additional query arguments to reduce the number of results returned.

Here is an example using posts_per_page, post_type, and category_name arguments.

$my_field->add_field( array(
    'name'    => __( 'Attached Posts', 'cmb2' ),
    'desc'    => __( 'Drag posts from the left column to the right column to attach them to this post.', 'cmb2' ),
    'id'      => 'attached_posts',
    'type'    => 'custom_attached_posts',
    'options' => array(
      'show_thumbnails' => true, // Show thumbnails on the left
      'filter_boxes'    => true, // Show a text box for filtering the results
      'query_args'      => array(
        'posts_per_page' => -1,
        'post_type'      => 'post',
        'category_name'  => 'videos'
      ), // override the get_posts args
    ),
  ) );
@erikberger

This comment has been minimized.

erikberger commented Oct 16, 2017

This pull request is a fix for this issue: #41 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment