WPCloudDeploy Documentation

Add Custom Search Fields To The App (Site) List

Did you add some custom fields to the WPCloudDeploy APP custom post type (‘wpcd_app’), but now want the search in the app list to include those fields?  Or maybe you want to include one of our APP CPT fields that we aren’t searching now (eg: the wpcd_site_status_push field.)

Here’s how you would do that.

Assuming you already have a custom plugin on your WPCD site, you need to add the following to let WordPress know you want to hook into one of our hooks:

add_filter( 'wpcd_app_search_fields', array( $this, 'wpcd_app_my_custom_search_fields' ), 10, 1 );
That line goes into the CONSTRUCTOR function of  your class.  Or, if you’re not using a PHP class, use this instead.
add_filter( 'wpcd_app_search_fields',  'wpcd_app_my_custom_search_fields' ) );
Then, add this function:
 * Include additional search fields when searching the app list.
 * Filter Hook: wpcd_app_search_fields
 * @see class-wpcd-posts-app.php - function wpcd_app_extend_admin_search
 * @param array $search_fields The current list of fields.
public function wpcd_app_my_custom_search_fields( $search_fields ) {
     /* Replace your fields in the array below */
     $our_search_fields = array(
    $search_fields = array_merge( $search_fields, $our_search_fields );
    return $search_fields;

You just need to replace your field names in the array.

If you’re not using a PHP class, you’ll need to remove the ‘public’ from the function definition.

Now, when you search for a value using the search box in the app/site list, it should pick up any values in your custom fields and filter the list accordingly.