Title: WP_Customize_Selective_Refresh::add_dynamic_partials
Published: April 12, 2016
Last modified: August 20, 2026

---

# WP_Customize_Selective_Refresh::add_dynamic_partials( string[] $partial_ids ): 󠀁[WP_Customize_Partial](https://developer.wordpress.org/reference/classes/wp_customize_partial/)󠁿[]

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/add_dynamic_partials/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/add_dynamic_partials/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/add_dynamic_partials/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/add_dynamic_partials/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/add_dynamic_partials/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/add_dynamic_partials/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/add_dynamic_partials/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/add_dynamic_partials/?output_format=md#changelog)

Registers dynamically-created partials.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/add_dynamic_partials/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/add_dynamic_partials/?output_format=md#see-also)󠁿

 * [WP_Customize_Manager::add_dynamic_settings()](https://developer.wordpress.org/reference/classes/WP_Customize_Manager/add_dynamic_settings/)

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

 `$partial_ids`string[]required

Array of the partial IDs to add.

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

 [WP_Customize_Partial](https://developer.wordpress.org/reference/classes/wp_customize_partial/)[]
Array of added [WP_Customize_Partial](https://developer.wordpress.org/reference/classes/wp_customize_partial/)
instances.

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

    ```php
    public function add_dynamic_partials( $partial_ids ) {
    	$new_partials = array();

    	foreach ( $partial_ids as $partial_id ) {

    		// Skip partials already created.
    		$partial = $this->get_partial( $partial_id );
    		if ( $partial ) {
    			continue;
    		}

    		$partial_args  = false;
    		$partial_class = 'WP_Customize_Partial';

    		/**
    		 * Filters a dynamic partial's constructor arguments.
    		 *
    		 * For a dynamic partial to be registered, this filter must be employed
    		 * to override the default false value with an array of args to pass to
    		 * the WP_Customize_Partial constructor.
    		 *
    		 * @since 4.5.0
    		 *
    		 * @param false|array $partial_args The arguments to the WP_Customize_Partial constructor.
    		 * @param string      $partial_id   ID for dynamic partial.
    		 */
    		$partial_args = apply_filters( 'customize_dynamic_partial_args', $partial_args, $partial_id );
    		if ( false === $partial_args ) {
    			continue;
    		}

    		/**
    		 * Filters the class used to construct partials.
    		 *
    		 * Allow non-statically created partials to be constructed with custom WP_Customize_Partial subclass.
    		 *
    		 * @since 4.5.0
    		 *
    		 * @param string $partial_class WP_Customize_Partial or a subclass.
    		 * @param string $partial_id    ID for dynamic partial.
    		 * @param array  $partial_args  The arguments to the WP_Customize_Partial constructor.
    		 */
    		$partial_class = apply_filters( 'customize_dynamic_partial_class', $partial_class, $partial_id, $partial_args );

    		$partial = new $partial_class( $this, $partial_id, $partial_args );

    		$this->add_partial( $partial );
    		$new_partials[] = $partial;
    	}
    	return $new_partials;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/customize/class-wp-customize-selective-refresh.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/customize/class-wp-customize-selective-refresh.php#L205)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/customize/class-wp-customize-selective-refresh.php#L205-L255)

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

 [apply_filters( ‘customize_dynamic_partial_args’, false|array $partial_args, string $partial_id )](https://developer.wordpress.org/reference/hooks/customize_dynamic_partial_args/)

Filters a dynamic partial’s constructor arguments.

 [apply_filters( ‘customize_dynamic_partial_class’, string $partial_class, string $partial_id, array $partial_args )](https://developer.wordpress.org/reference/hooks/customize_dynamic_partial_class/)

Filters the class used to construct partials.

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

| Uses | Description | 
| [WP_Customize_Selective_Refresh::get_partial()](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/get_partial/)`wp-includes/customize/class-wp-customize-selective-refresh.php` |

Retrieves a partial.

  | 
| [WP_Customize_Selective_Refresh::add_partial()](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/add_partial/)`wp-includes/customize/class-wp-customize-selective-refresh.php` |

Adds a partial.

  | 
| [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.

  |

[Show 1 more](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/add_dynamic_partials/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/add_dynamic_partials/?output_format=md#)

| Used by | Description | 
| [WP_Customize_Selective_Refresh::handle_render_partials_request()](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/handle_render_partials_request/)`wp-includes/customize/class-wp-customize-selective-refresh.php` |

Handles the Ajax request to return the rendered partials for the requested placements.

  |

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

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

## User Contributed Notes

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