How to access options of Redux framework in front end

I’m creating a wordpress theme in which I’m using the Redux Framework for creating the theme’s options page. Now I believe everything is well set up but I’m having trouble in getting the values changed by Redux in my front end.

For example I checked one of the checkbox in the settings panel had this attribute: name=”redux_demo[10]”, so in my front end I did this:

Read More
    <?php 
    if(get_option('redux_demo[10]')) { ?>  

      <h1>Text</h1>  

    <?php 
    }?>

But Text is not showing whether I save it as checked or unchecked. I also tried the following but it’s also not working:

    <?php 
    if(get_option('redux_demo[10]') === 1) { ?>

      <h1>Text</h1>  

    <?php 
    }?>

I searched a lot in the docs and also on the internet but I can’t find any tutorial that shows how to actually retrieve data saved by redux. Please let me know if you have any idea about this.

Thank you very much.

Related posts

2 comments

  1. I have no idea how the framework actually stores its options, but I guess it uses the name redux_demo, not redux_demo[10]. If the option is an array, you can access the element 10 like this:

    $redux_demo = get_option( 'redux_demo' );
    
    if ( ! empty ( $redux_demo[ 10 ] ) and 1 === $redux_demo[ 10 ] )
    {
        print '<h1>Text</h1>';
    }
    
  2. Redux actually stores your saved settings in a global variable which is established in your redux config file (public function setArguements) under opt_name, in this case $redux_demo. You can choose which option you want to display by referencing the unique ID of that option. Here’s an example:

    <?php
    global $redux_demo;
    if( $redux_demo['10'] === 1 ) { ?>
        <h1>Text</h1>
    <?php } ?>
    

    Hope that helps!

Comments are closed.