In my plugin I have in admin menu function Media Organizations List. Here I get a list of all Organizations. There are 3 organizations types

  • affiliate
  • direct
  • bureau

The total list will get long. Therefor I need a custom hook to filter the 3 organization types to get a better view.

I have read several documents but not understand exact what to do.

Is there someone of you who can help me making this custom hook? It would be very helpful.


1 Answer 1


First, register the filter hooks with the handy apply_filters tool:

function wpse_238394_org_types() {
    return apply_filters(
        array( "affiliate", "direct", "bureau" )

Now, wpse_238394_org_types() will return the default 3 types being not filtered yet, so we one more custom type:

add_filter("my_org_types", function($types) { 
    $types[] = "custom_type";
    return $types;

Now if you debug wpse_238394_org_types() it should be including the custom_type item along the defaults.

Hope that helps. Please also take a look at the docs https://developer.wordpress.org/plugins/hooks/creating-custom-hooks/ as jdm2112 suggested.

  • Thanks. Have add function wpse_238394_org_types() { into class List_Table_banner_affiliates extends WP_List_Table { But where to save add_filter("my_org_types", function($types) { ??
    – Hermants
    Commented Sep 7, 2016 at 13:39
  • add_filter part can be used in a plugin, or in the child theme's functions file.. Just anywhere in your plugin e.g in the class init method.
    – Ismail
    Commented Sep 7, 2016 at 13:42
  • add_filter part is added in my plugin. How do I get to see these filter options on my my-plugin/includes/affliates.php file?
    – Hermants
    Commented Sep 7, 2016 at 14:47
  • Whenever you call for the types use the function wpse_238394_org_types().. var_dump( wpse_238394_org_types() )
    – Ismail
    Commented Sep 7, 2016 at 17:03
  • I've got array(4) { [0]=> string(9) "affiliate" [1]=> string(6) "direct" [2]=> string(6) "bureau" [3]=> string(11) "custom_type" } ; Thats a start. But how to get this as filter at the top of the listing including that they indeed filter the listing as needed. Sorry but I am not familiar with this at all. And the docs do not give me a good help at all.
    – Hermants
    Commented Sep 7, 2016 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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