Title: postbox_classes
Published: April 25, 2014
Last modified: February 24, 2026

---

# postbox_classes( string $box_id, string $screen_id ): string

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/postbox_classes/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/postbox_classes/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/postbox_classes/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/postbox_classes/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/postbox_classes/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/postbox_classes/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/postbox_classes/?output_format=md#wp--skip-link--target)

Returns the list of classes to be used by a meta box.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/postbox_classes/?output_format=md#parameters)󠁿

 `$box_id`stringrequired

Meta box ID (used in the `'id'` attribute for the meta box).

`$screen_id`stringrequired

The screen on which the meta box is shown.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/postbox_classes/?output_format=md#return)󠁿

 string Space-separated string of class names.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/postbox_classes/?output_format=md#source)󠁿

    ```php
    function postbox_classes( $box_id, $screen_id ) {
    	if ( isset( $_GET['edit'] ) && $_GET['edit'] === $box_id ) {
    		$classes = array( '' );
    	} elseif ( get_user_option( 'closedpostboxes_' . $screen_id ) ) {
    		$closed = get_user_option( 'closedpostboxes_' . $screen_id );
    		if ( ! is_array( $closed ) ) {
    			$classes = array( '' );
    		} else {
    			$classes = in_array( $box_id, $closed, true ) ? array( 'closed' ) : array( '' );
    		}
    	} else {
    		$classes = array( '' );
    	}

    	/**
    	 * Filters the postbox classes for a specific screen and box ID combo.
    	 *
    	 * The dynamic portions of the hook name, `$screen_id` and `$box_id`, refer to
    	 * the screen ID and meta box ID, respectively.
    	 *
    	 * @since 3.2.0
    	 *
    	 * @param string[] $classes An array of postbox classes.
    	 */
    	$classes = apply_filters( "postbox_classes_{$screen_id}_{$box_id}", $classes );

    	return implode( ' ', $classes );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/post.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/post.php#L1424)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/post.php#L1424-L1451)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/postbox_classes/?output_format=md#hooks)󠁿

 [apply_filters( “postbox_classes_{$screen_id}_{$box_id}”, string[] $classes )](https://developer.wordpress.org/reference/hooks/postbox_classes_screen_id_box_id/)

Filters the postbox classes for a specific screen and box ID combo.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/postbox_classes/?output_format=md#related)󠁿

| Uses | Description | 
| [get_user_option()](https://developer.wordpress.org/reference/functions/get_user_option/)`wp-includes/user.php` |

Retrieves user option that can be either per Site or per Network.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

| Used by | Description | 
| [do_meta_boxes()](https://developer.wordpress.org/reference/functions/do_meta_boxes/)`wp-admin/includes/template.php` |

Meta-Box template function.

  | 
| [do_accordion_sections()](https://developer.wordpress.org/reference/functions/do_accordion_sections/)`wp-admin/includes/template.php` |

Meta Box Accordion Template Function.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/postbox_classes/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.5.0](https://developer.wordpress.org/reference/since/2.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fpostbox_classes%2F)
before being able to contribute a note or feedback.