Search code examples
phpredux-framework

How to display Redux Framework options in theme


Im new with Redux Framework and Im removing propanel and Im adding Redux instead but the options now not working

For example an exsisting option in my theme for related videos:

<?php 
$relatedvideosbase = get_option('mytheme_relatedvideos');
if ($relatedvideosbase == "tags") {
get_template_part( 'related/tags', get_post_format() ); 
} elseif ($relatedvideosbase == "category") { 
get_template_part( 'related/category', get_post_format() ); 
} elseif ($relatedvideosbase == "random") { 
get_template_part( 'related/random', get_post_format() );
} else {
get_template_part( 'related/tags', get_post_format() ); 
}   
?>

The Above code was working fine with propanel and I removed propanel now added the redux framework and Created the option like this:

    array(
        'id'       => '_relatedvideos',
        'type'     => 'button_set',
        'title'    => __( 'Related Videos by?', 'redux-framework-demo' ),
        //Must provide key => value pairs for radio options
        'options'  => array(
             'tags' => __('Tags','redux-framework-demo'),
            'category' => __('Category','redux-framework-demo'),
            'random' => __('Random','redux-framework-demo')
        ),
        'default'  => 'random'
    ), 

Changed also the opt name as I had in propanel $opt_name = 'mytheme'; but with redux framework I cant figure it out, is there any way ? thanks..


Solution

  • you need to add the global $redux_demo before your code like below

    global $redux_demo; // This is your opt_name.
    

    and to echo the option

    echo $redux_demo['the option id'];
    

    change the $redux_demo to your option name and change the option id to your option id

    https://docs.reduxframework.com/core/getting-started/