W3cubDocs

/WordPress

WP_Theme_JSON::append_to_selector( string $selector, string $to_append ): string

Appends a sub-selector to an existing one.

Description

Given the compounded $selector "h1, h2, h3" and the $to_append selector ".some-class" the result will be "h1.some-class, h2.some-class, h3.some-class".

Parameters

$selectorstringrequired
Original selector.
$to_appendstringrequired
Selector to append.

Return

string The new selector.

Source

* }
*
* It returns the following output:
*
* {
*   "styles": {
*     "blocks": {
*       "core/paragraph": {
*         "variations": {
*             "section-a": { "color": { "background": "backgroundColor" } }
*         },

Changelog

Version Description
6.3.0 Removed append position parameter.
6.1.0 Added append position.
5.8.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json/append_to_selector