I’m building a Theme Options page for my theme, and I’ve managed to get most of it working fine. But now I’m trying to show and hide certain parts in my theme based on a simple check box. An example:
Show featured content slider ?
– Yes
– No
When the user selects yes I want to enable the following code in a certain template of my theme:
<?php locate_template( array( 'includes/slider.php'), true ) ?>
So how can I wrap this code so that it only shows when Yes is clicked? I think it’s some kind of conditional statement but I have now idea how to approach this. Since I can’t write php I need some help with this 🙂 The name of the option is called bpslick_featured.
Thanks in advance!
@Bowe
You would need to create an array in your options function for the checkbox and give it an id a default state and assign the “checkbox” type to it. Here is a sample assuming you already have the code in place for the admin panel
Next add the function in functions.php that calls the slider if the box is checked.
This code has not been checked to make sure it works exactly as is but meant to show an example for using a checkbox option in your theme.