Created
April 26, 2013 18:22
-
-
Save nathanielks/5469306 to your computer and use it in GitHub Desktop.
These functions will programmatically add widgets to a specified sidebar. This can be useful when a theme is first installed to fill specific sidebars with widgets you're written for your theme. $add_to_sidebar takes the id of the sidebar you wish to add to. $widgets takes the id's of the widgets you wish to add.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('after_setup_theme', 'cur_setup_theme'); | |
function cur_setup_theme(){ | |
if(!get_option('cur_widgets_installed',false)){ | |
$add_to_sidebar = 'primary-navigation'; | |
// $widgets is an array of widget id's | |
$widgets = array( | |
'search', | |
); | |
cur_add_widgets_to_sidebar( $add_to_sidebar, $widgets ); | |
update_option('cur_widgets_installed',true); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment