I created some functions in my theme functions.php file, and I call the main function in the header.php file, and store the result into a variable, I want to use this value in a widget.
Is it possible ?
I created some functions in my theme functions.php file, and I call the main function in the header.php file, and store the result into a variable, I want to use this value in a widget.
Is it possible ?
You must be logged in to post a comment.
Have you tried this?
http://wordpress.org/extend/plugins/php-code-widget/
There are other plugins out there that do the same thing: allow execution of PHP in text widgets.
You can save variables such as theme options in the wp_options table.
To add set a value, use update_option() and to read that value, use get_option.
add_option() can also be used but it works only if the variable doesn’t exist in the database. Hence, update_option() is preferred.
In widget for get variable just use: