How to use Option Framework in WP Theme
Option Framework(SMOF) a popular wordpress option framework for theme option UI. SMOF – Slightly Modded Options Framework. Really this UI looking better than other option framework theme option like option tree but SMOF framework only for theme option. The framework can not use in metaboxes. Ok, now let’s start how to use SMOF framework in theme.
Step-1. Download SMOF
Step-2. Copy admin & images folder in theme directory. And turn off WP_DEBUG. You can turn it on later for debugging.
Step-3. Open functions.php then add require_once (‘admin/index.php’); this code.
Step-4. Go on admin/fuctions/functions.options.php file, then add your options. You can create section & options under section from demo.
Step-5. For getting data drom thene option, use this code in your theme php: <?php echo do_shortcode(stripslashes($data[‘your_id’])); ?> also can use <?php global $data; echo $data[‘your_id’]; ?> but first one.
To learn more about SMOF click here and see the code for use conditional used
//Conditional Options in functions $of_options = array( "name" => "Show Banner", "desc" => "You can use banner below logo and description", "id" => "show_banner", "on" => "Yes, I'd like to show banner", "off" => "Sorry, I don't want banner", "std" => 0, "folds" => 1, "type" => "switch" ); $of_options = array( "name" => "Upload your banner", "desc" => "You can upload your banner from here", "id" => "custom_banner", "fold" => "show_banner", /* the switch hook */ "type" => "upload" ); //Conditional Banner code in theme <?php global $data; ?> <?php if($data['show_banner']): ?> <img src="<?php echo $data['custom_banner']; ?>" alt="" /> <?php else: ?> <?php endif; ?>
If faced any problem to use the SMOF option framework comment here.
Comments are closed