1

Is it possible to use redux values with echo in a custom made widget?

my-widget.php is included in function.php with global $opt_name defined in top of fuction.php

Want to use:

echo $opt_name['very-nice-input'];

Excerpt from my-widget.php showing front-end display of widget.

echo $args['before_widget'];
if ( ! empty( $instance['title'] ) ) {
    echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];
}
    echo $opt_name['very-nice-input'];
    echo $args['after_widget'];
}

1 Answer 1

1

Lead dev of Redux here.

Yes, but you may need to do your own get_option('OPT_NAME') if the values haven't been set yet. Give it a try by declaring your global $OPT_NAME variable. If it's empty, then do a get_option.

:)

Sign up to request clarification or add additional context in comments.

3 Comments

For further reference if someone googles this question: I thought that declaring global $OPT_NAME; in function.php would be enough as I included my widget in the bottom of function.php. It showed out that I needed to include global $OPT_NAME; in my-widget.php also.
Addition: Declare global $OPT_NAME; inside public function widget, or whatever php-function you need the values accessible in.
There you go. :) Glad you got it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.