wp_add_inline_script

SummerySummery

Adds extra code to a registered script.

Syntax

wp_add_inline_script( string $handle, string $data, string $position = 'after' )

DescriptionDescription

Code will only be added if the script is already in the queue. Accepts a string $data containing the Code. If two or more code blocks are added to the same script $handle, they will be printed in the order they were added, i.e. the latter added code can redeclare the previous.

ParametersParameters

$handle

(string) (Required) Name of the script to add the inline script to.

$data

(string) (Required) String containing the javascript to be added.

$position

(string) (Optional) Whether to add the inline script before the handle or after.

Default value: 'after'

ReturnReturn

(bool) True on success, false on failure.

SourceSource

File: wp-includes/functions.wp-scripts.php


			

ChangelogChangelog

Changelog
Version Description
4.5.0 Introduced.

See alsoSee also

Scroll to Top