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

---

# WP_Customize_Control::render_content()

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_customize_control/render_content/?output_format=md#description)
 * [Source](https://developer.wordpress.org/reference/classes/wp_customize_control/render_content/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_customize_control/render_content/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_customize_control/render_content/?output_format=md#changelog)

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

Renders the control’s content.

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

Allows the content to be overridden without having to rewrite the wrapper in `$this::
render()`.

Supports basic input types `text`, `checkbox`, `textarea`, `radio`, `select` and`
dropdown-pages`.
Additional input types such as `email`, `url`, `number`, `hidden`
and `date` are supported implicitly.

Control content can alternately be rendered in JS. See [WP_Customize_Control::print_template()](https://developer.wordpress.org/reference/classes/wp_customize_control/print_template/).

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

    ```php
    protected function render_content() {
    	$input_id         = '_customize-input-' . $this->id;
    	$description_id   = '_customize-description-' . $this->id;
    	$describedby_attr = ( ! empty( $this->description ) ) ? ' aria-describedby="' . esc_attr( $description_id ) . '" ' : '';
    	switch ( $this->type ) {
    		case 'checkbox':
    			?>
    			<span class="customize-inside-control-row">
    				<input
    					id="<?php echo esc_attr( $input_id ); ?>"
    					<?php echo $describedby_attr; ?>
    					type="checkbox"
    					value="<?php echo esc_attr( $this->value() ); ?>"
    					<?php $this->link(); ?>
    					<?php checked( $this->value() ); ?>
    				/>
    				<label for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_html( $this->label ); ?></label>
    				<?php if ( ! empty( $this->description ) ) : ?>
    					<span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
    				<?php endif; ?>
    			</span>
    			<?php
    			break;
    		case 'radio':
    			if ( empty( $this->choices ) ) {
    				return;
    			}

    			$name = '_customize-radio-' . $this->id;
    			?>
    			<?php if ( ! empty( $this->label ) ) : ?>
    				<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
    			<?php endif; ?>
    			<?php if ( ! empty( $this->description ) ) : ?>
    				<span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
    			<?php endif; ?>

    			<?php foreach ( $this->choices as $value => $label ) : ?>
    				<span class="customize-inside-control-row">
    					<input
    						id="<?php echo esc_attr( $input_id . '-radio-' . $value ); ?>"
    						type="radio"
    						<?php echo $describedby_attr; ?>
    						value="<?php echo esc_attr( $value ); ?>"
    						name="<?php echo esc_attr( $name ); ?>"
    						<?php $this->link(); ?>
    						<?php checked( $this->value(), $value ); ?>
    						/>
    					<label for="<?php echo esc_attr( $input_id . '-radio-' . $value ); ?>"><?php echo esc_html( $label ); ?></label>
    				</span>
    			<?php endforeach; ?>
    			<?php
    			break;
    		case 'select':
    			if ( empty( $this->choices ) ) {
    				return;
    			}

    			?>
    			<?php if ( ! empty( $this->label ) ) : ?>
    				<label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label>
    			<?php endif; ?>
    			<?php if ( ! empty( $this->description ) ) : ?>
    				<span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
    			<?php endif; ?>

    			<select id="<?php echo esc_attr( $input_id ); ?>" <?php echo $describedby_attr; ?> <?php $this->link(); ?>>
    				<?php
    				foreach ( $this->choices as $value => $label ) {
    					echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . esc_html( $label ) . '</option>';
    				}
    				?>
    			</select>
    			<?php
    			break;
    		case 'textarea':
    			if ( ! array_key_exists( 'rows', $this->input_attrs ) ) {
    				$this->input_attrs['rows'] = 5;
    			}
    			?>
    			<?php if ( ! empty( $this->label ) ) : ?>
    				<label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label>
    			<?php endif; ?>
    			<?php if ( ! empty( $this->description ) ) : ?>
    				<span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
    			<?php endif; ?>
    			<textarea
    				id="<?php echo esc_attr( $input_id ); ?>"
    				<?php echo $describedby_attr; ?>
    				<?php $this->input_attrs(); ?>
    				<?php $this->link(); ?>
    			><?php echo esc_textarea( $this->value() ); ?></textarea>
    			<?php
    			break;
    		case 'dropdown-pages':
    			?>
    			<?php if ( ! empty( $this->label ) ) : ?>
    				<label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label>
    			<?php endif; ?>
    			<?php if ( ! empty( $this->description ) ) : ?>
    				<span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
    			<?php endif; ?>

    			<?php
    			$dropdown_name     = '_customize-dropdown-pages-' . $this->id;
    			$show_option_none  = __( '&mdash; Select &mdash;' );
    			$option_none_value = '0';
    			$dropdown          = wp_dropdown_pages(
    				array(
    					'name'              => $dropdown_name,
    					'echo'              => 0,
    					'show_option_none'  => $show_option_none,
    					'option_none_value' => $option_none_value,
    					'selected'          => $this->value(),
    				)
    			);
    			if ( empty( $dropdown ) ) {
    				$dropdown  = sprintf( '<select id="%1$s" name="%1$s">', esc_attr( $dropdown_name ) );
    				$dropdown .= sprintf( '<option value="%1$s">%2$s</option>', esc_attr( $option_none_value ), esc_html( $show_option_none ) );
    				$dropdown .= '</select>';
    			}

    			// Hackily add in the data link parameter.
    			$dropdown = str_replace( '<select', '<select ' . $this->get_link() . ' id="' . esc_attr( $input_id ) . '" ' . $describedby_attr, $dropdown );

    			/*
    			 * Even more hackily add auto-draft page stubs.
    			 * @todo Eventually this should be removed in favor of the pages being injected into the underlying get_pages() call.
    			 * See <https://github.com/xwp/wp-customize-posts/pull/250>.
    			 */
    			$nav_menus_created_posts_setting = $this->manager->get_setting( 'nav_menus_created_posts' );
    			if ( $nav_menus_created_posts_setting && current_user_can( 'publish_pages' ) ) {
    				$auto_draft_page_options = '';
    				foreach ( $nav_menus_created_posts_setting->value() as $auto_draft_page_id ) {
    					$post = get_post( $auto_draft_page_id );
    					if ( $post && 'page' === $post->post_type ) {
    						$auto_draft_page_options .= sprintf( '<option value="%1$s">%2$s</option>', esc_attr( $post->ID ), esc_html( $post->post_title ) );
    					}
    				}
    				if ( $auto_draft_page_options ) {
    					$dropdown = str_replace( '</select>', $auto_draft_page_options . '</select>', $dropdown );
    				}
    			}

    			echo $dropdown;
    			?>
    			<?php if ( $this->allow_addition && current_user_can( 'publish_pages' ) && current_user_can( 'edit_theme_options' ) ) : // Currently tied to menus functionality. ?>
    				<button type="button" class="button-link add-new-toggle">
    					<?php
    					/* translators: %s: Add Page label. */
    					printf( __( '+ %s' ), get_post_type_object( 'page' )->labels->add_new_item );
    					?>
    				</button>
    				<div class="new-content-item-wrapper">
    					<label for="create-input-<?php echo esc_attr( $this->id ); ?>"><?php _e( 'New page title' ); ?></label>
    					<div class="new-content-item">
    						<input type="text" id="create-input-<?php echo esc_attr( $this->id ); ?>" class="create-item-input form-required">
    						<button type="button" class="button add-content"><?php _e( 'Add' ); ?></button>
    					</div>
    					<span id="create-input-<?php echo esc_attr( $this->id ); ?>-error" class="create-item-error error-message" style="display: none;"><?php _e( 'Please enter a page title' ); ?></span>

    				</div>
    			<?php endif; ?>
    			<?php
    			break;
    		default:
    			?>
    			<?php if ( ! empty( $this->label ) ) : ?>
    				<label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label>
    			<?php endif; ?>
    			<?php if ( ! empty( $this->description ) ) : ?>
    				<span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
    			<?php endif; ?>
    			<input
    				id="<?php echo esc_attr( $input_id ); ?>"
    				type="<?php echo esc_attr( $this->type ); ?>"
    				<?php echo $describedby_attr; ?>
    				<?php $this->input_attrs(); ?>
    				<?php if ( ! isset( $this->input_attrs['value'] ) ) : ?>
    					value="<?php echo esc_attr( $this->value() ); ?>"
    				<?php endif; ?>
    				<?php $this->link(); ?>
    				/>
    			<?php
    			break;
    	}
    }
    ```

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

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

| Uses | Description | 
| [WP_Customize_Control::input_attrs()](https://developer.wordpress.org/reference/classes/wp_customize_control/input_attrs/)`wp-includes/class-wp-customize-control.php` |

Renders the custom attributes for the control’s input element.

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

Escaping for textarea values.

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

Outputs the HTML checked attribute.

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

Outputs the HTML selected attribute.

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

Retrieves or displays a list of pages as a dropdown (select list).

  | 
| [WP_Customize_Control::link()](https://developer.wordpress.org/reference/classes/wp_customize_control/link/)`wp-includes/class-wp-customize-control.php` |

Renders the data link attribute for the control’s input element.

  | 
| [WP_Customize_Control::get_link()](https://developer.wordpress.org/reference/classes/wp_customize_control/get_link/)`wp-includes/class-wp-customize-control.php` |

Gets the data link attribute for a setting.

  | 
| [WP_Customize_Control::value()](https://developer.wordpress.org/reference/classes/wp_customize_control/value/)`wp-includes/class-wp-customize-control.php` |

Fetches a setting’s value.

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

Returns whether the current user has the specified capability.

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

Retrieves the translation of $text.

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

Displays translated text.

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

Escaping for HTML attributes.

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

Escaping for HTML blocks.

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

Retrieves post data given a post ID or post object.

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

Retrieves a post type object by name.

  |

[Show 10 more](https://developer.wordpress.org/reference/classes/wp_customize_control/render_content/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_customize_control/render_content/?output_format=md#)

| Used by | Description | 
| [WP_Customize_Control::render()](https://developer.wordpress.org/reference/classes/wp_customize_control/render/)`wp-includes/class-wp-customize-control.php` |

Renders the control wrapper and calls $this->render_content() for the internals.

  |

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

| Version | Description | 
| [3.4.0](https://developer.wordpress.org/reference/since/3.4.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_control%2Frender_content%2F)
before being able to contribute a note or feedback.