• chibib0

    (@chibib0)


    Hi,

    I have set up a settings api using this tutorial,
    https://alisothegeek.com/2011/04/wordpress-settings-api-tutorial-follow-up/

    And having this setting which adds a dropdown box to choose between “catalog” and “shopping cart”,

    $this->settings['store_type'] = array(
    			'section' => 'general',
    			'title'   => __( '<b>Store Type</b> <a href="#"><img src="https://cdn4.iconfinder.com/data/icons/Sizicons/12x12/question_blue.png" border="0" /></a>' ),
    			'desc'    => __( 'Choose the type of your store' ),
    			'type'    => 'select',
    			'std'     => 'Shopping Cart',
    			'choices' => array(
    				'cart' => 'Shopping Cart',
    				'catalog' => 'Catalog',
    			)
    		);

    I wanted to have an if condition or any solution like,

    if “catalog” is selected {
    // do anything as catalog.
    } elseif “shopping cart” is selected {
    // do anything as shopping cart.
    }

    Please help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • accounts@push

    (@accountspush)

    you should be using a statement like if ($settings['store_type']== "catalogue") echo 'ect...

    then if your “else” statement is required then its pretty straight forward

    if that doesn’t work then id consider reading up on the if and else statements and their parameters

    accounts@push

    (@accountspush)

    actually going back to the code you posted it seems like you’ve got an array stored within an array – or your trying to do that – id be keeping everything into one array and then just referring to it in the ‘if’ statement like i posted before – it would be easier to work with.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘IF condition for wordpress dropdown settings api’ is closed to new replies.