On this page
apply_filters( "pre_option_{$option}", mixed $pre_option, string $option, mixed $default )
Filters the value of an existing option before it is retrieved.
Description
The dynamic portion of the hook name, $option, refers to the option name.
Returning a value other than false from the filter will short-circuit retrieval and return that value instead.
Parameters
$pre_optionmixed-
The value to return instead of the option value. This differs from
$default, which is used as the fallback value in the event the option doesn't exist elsewhere in get_option() .
Default false (to skip past the short-circuit). $optionstring-
Option name.
$defaultmixed-
The fallback value to return if the option does not exist.
Default false.
More Information
- This hook is used to temporarily alter a WordPress option before the display of a specific view. WordPress options (e.g. the blog configuration) are usually set in the back-end by the user or programmatically by a plugin. The options are stored in the database. To alter the value of an option during the rendering of a page without changing it permanently in the database, you may use this hook.
- Example option name {$option} can the following:
pre_option_posts_per_page
pre_option_posts_per_rss
pre_option_template
pre_option_stylesheet
pre_option_blog_charset
pre_option_home
...
- For a list of all available options, call
wp_load_alloptions()
which returns the list of available options as an array that you could store in a variable or display for debugging purposes.
Source
File: wp-includes/option.php. View all references
$pre = apply_filters( "pre_option_{$option}", false, $option, $default );
Related
Used By
| Used By | Description |
|---|---|
| get_option() wp-includes/option.php | Retrieves an option value based on an option name. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/hooks/pre_option_option