0

We use a 3rd party custom post type for events in which they have removed the ability to filter the posts.

Events List

I would like to add the option to filter the posts by event date. I have found plenty of examples on adding a filter but I can't find anything for adding the "Filter" button.

Posts List

Does anyone know if it is possible to add this button and if so, how?

0

If you mean the usual months dropdown, then most likely the plugin might be disabling it via the following filter:

/**
 * Filters whether to remove the 'Months' drop-down from the post list table.
 *
 * @since 4.2.0
 *
 * @param bool   $disable   Whether to disable the drop-down. Default false.
 * @param string $post_type The post type.
 */

 if ( apply_filters( 'disable_months_dropdown', false, $post_type ) ) {
     return;
 }

You could try to override it with:

add_filter( 'disable_months_dropdown', function( $disable, $post_type )
{
    return 'event' === $post_type ? true :$disable;
}, 999, 2 );

where you might need to adjust the post type slug and priority to your needs.

  • Thanks but no luck. I checked the plugin and couldn't find a filter using 'disable_months_dropdown'. I found I could create/add other filters, it's just getting the "filter" submit button back to process it. – PthPndr Dec 3 '16 at 23:33
0

Well, in my case I found how they were hiding the date dropdown and filter button.

.events-cal .tablenav select[name=m], .events-cal #post-query-submit {
    display: none;
}

At least I can overwrite their CSS and get both of those functions back. Thank you.

  • It crossed my mind, that this could be the case, but I doubted the plugin author would use it because the usual way is to use the filter, but I was wrong ;-) Please accept your answer to close the question. – birgire Dec 4 '16 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.