Code Monkey home page Code Monkey logo

wordpress_admin_custom_field_filter's Introduction

Wordpress_Admin_Custom_Field_Filter

A class to add a selectbox filter by custom field value in Custom Post Type listing page in admin

Usage

To add a select-box filter to any Post Type/Custom Post Type listing page, just create new object

new Admin_Custom_Field_Filter(array('CUSTOM-POST-TYPE' => array('CUSTOM-FIELD-1','CUSTOM-FIELD-2')));

in which, 'CUSTOM-POST-TYPE' is the name of the post type/custom post type you want to add 'CUSTOM-FIELD-1', 'CUSTOM-FIELD-2' are the names of the custom fields you want to filter by. Add many custom fields as you want, each item will add new select-box

By default, items in the select-box filter will have Text value the same with it's Value. To modify this value, use filter

add_filter('admin_custom_field_filter_value','custom_admin_custom_field_filter_value',10,3);

For examle

function custom_admin_custom_field_filter_value($value,$custom_post_type,$custom_field){ if($custom_post_type == 'custom-post-type' && $custom_field == 'custom-field'){ $post = get_post($value); if($post){ return $post->post_title; } } return $value; }

wordpress_admin_custom_field_filter's People

Contributors

hadoanngoc avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.