Home › Forums › Calendar Products › Events Calendar PRO › Adding custom meta filter to Advanced Post Manager results in two metaboxes.
- This topic has 3 replies, 2 voices, and was last updated 10 years, 8 months ago by
Barry.
-
AuthorPosts
-
August 17, 2015 at 5:15 pm #996783
integrity
ParticipantI’m running the The Event Calendar, The Event Calendar Pro and the Advanced Post Manager all at version 3.10. (We rolled back to 3.10 because of some community events problems.) These are the only three plugins currently activated. I added the following snippet of code to my functions.php file in order to add a new filter/column to the backend Events page:
add_action('init', 'setup_cpt_filters'); function setup_cpt_filters() { global $my_cpt_filters; $filter_array = array( 'my_meta_filter_key' => array( 'name' => 'Funded by XYZ', 'meta' => '_ecp_custom_2' ) ); $my_cpt_filters = tribe_setup_apm('tribe_events', $filter_array); }This resulted in two metaboxes with the same id (“tribe-filters”) appearing on the backend Events page. Both metaboxes are partially broken. One of them can successfully add filters (the other does nothing when you select a filter from the dropdown). This one’s dropdown only includes my custom filter, “Event Categories” and “Tags.” The other can successfully add columns (the other does nothing when you select a column from the dropdown and the column options cannot be dragged and reordered). My custom filter appears as a column in both metaboxes.
Clicking “Apply” works on both metaboxes.
If I changed my code snippet to specific a non-default metabox, the same problem occurs.
add_action('init', 'setup_cpt_filters'); function setup_cpt_filters() { global $my_cpt_filters; $filter_array = array( 'my_meta_filter_key' => array( 'name' => 'Funded by XYZ', 'meta' => '_ecp_custom_2', 'metabox' => 'unique_box' ) ); $metaboxes = array( 'unique_box' => 'A Unique Box'); $my_cpt_filters = tribe_setup_apm('tribe_events', $filter_array, $metaboxes); }Album of images of the issue: http://imgur.com/a/1jPvs








Is this a bug? User error? Ghosts?
August 18, 2015 at 7:17 am #996967Barry
MemberHi @integrity,
Thanks for the question. The first thing I have to highlight is that we can’t go into too much depth with custom development questions like this one, but I’d be happy to explore it a little and hopefully get you pointed in the right direction 🙂
The second thing I would highlight is that the documentation that comes with Advanced Post Manager (which I think you have based your own code upon) isn’t really geared toward helping you manipulate the filters added by Events Calendar PRO: rather these are general purpose instructions that can help you add filters to any post type, regardless of whether Events Calendar PRO is activated or not.
In this case, your code is creating a second APM object for the same post type, hence the second set of filters. APM isn’t really designed to accommodate that scenario, exactly, and I think in any case you are interested in modifying and extending the APM object that Events Calendar PRO creates.
https://gist.github.com/barryhughes/74b14b0be8a6ad2c91f4
Does the above help at all in showing an alternative way to approach this?
August 18, 2015 at 8:59 am #997009integrity
ParticipantThat worked like a charm, thank you!
August 18, 2015 at 9:28 am #997013Barry
MemberGlad it helped 🙂
I’ll close this topic as you’ve marked it “resolved”, but of course please feel free to create new topics as needed and one of the team will be only too happy to assist.
Thanks again!
-
AuthorPosts
- The topic ‘Adding custom meta filter to Advanced Post Manager results in two metaboxes.’ is closed to new replies.
