0

The WPresidence theme has an action in its WPresidence-core that generates a dropdown filter on the estate_property post type admin table page the I've not been able to remove.

The function goes as such: they could have just made it pluggable but failed to do so

$restrict_manage_posts = function($post_type, $taxonomy) {
return function() use($post_type, $taxonomy) {
    global $typenow;

    if($typenow == $post_type) {
        $selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : '';
        $info_taxonomy = get_taxonomy($taxonomy);

        wp_dropdown_categories(array(
            'show_option_all'   => esc_html__("Show All {$info_taxonomy->label}"),
            'taxonomy'          => $taxonomy,
            'name'              => $taxonomy,
            'orderby'           => 'name',
            'selected'          => $selected,
            'show_count'        => TRUE,
            'hide_empty'        => TRUE,
            'hierarchical'      => true
        ));

    }

};

};

Then it hooks to 'restrict_manage_posts' like this

add_action('restrict_manage_posts', $restrict_manage_posts('estate_property', 'property_action_category') );

I have since created both a child theme and a plugin to override this with no luck thus far. Here's what I've tried below:

  add_action( 'restrict_manage_posts', 'remove_estate_filter', 9 );

    function remove_estate_filter(){
           
           // basicaly redeclare the function as is
          $restrict_manage_posts = function($post_type, $taxonomy) {
          return function() use($post_type, $taxonomy) {
        global $typenow;

        if($typenow == $post_type) {
            $selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : '';
            $info_taxonomy = get_taxonomy($taxonomy);

            wp_dropdown_categories(array(
                'show_option_all'   => esc_html__("Show All {$info_taxonomy->label}"),
                'taxonomy'          => $taxonomy,
                'name'              => $taxonomy,
                'orderby'           => 'name',
                'selected'          => $selected,
                'show_count'        => TRUE,
                'hide_empty'        => TRUE,
                'hierarchical'      => true
            ));

        }

    };

};
       // then try and remove it
       remove_action('restrict_manage_posts', $restrict_manage_posts('estate_property', 'property_action_category') );
    }

It is also important to note that I've tried the following hooks with various priorities as well just to get it to work but with no avail.

  • admin_notices
  • all_admin_notices
  • admin_init
  • restrict_manage_posts

Any help to get this nailed is very welcomed.

Thank you

  • This is a difficult one. As a workaround, maybe you can hide their dropdown via CSS (or remove with JS), copy their code and implement a modified version. – Howdy_McGee Oct 4 at 3:45

Your Answer

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

Browse other questions tagged or ask your own question.