Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Setting default widgets in twenty ten child theme?

  1. #1
    jwack is offline Hello World
    Join Date
    Aug 2009
    Posts
    46

    Default Setting default widgets in twenty ten child theme?

    I am making a Twentyten child theme but can't find any info on how to set the default widgets that are displayed when a new blog is created.


    For example, how do I populate the primary-widget-area and secondary-widget-area so when a blog is created it had the widgets I want in there?


    Thanks for any help!

  2. #2
    Remkus's Avatar
    Remkus is offline Hello World
    Join Date
    Feb 2009
    Location
    the Netherlands
    Posts
    32

    Default

    Take a look at the inside of Thematic. When activated it sports an activated widget or two..
    My company: ForSite Media | Twitter: @DeFries

  3. #3
    chipbennett's Avatar
    chipbennett is offline WordPress Legend
    Join Date
    Feb 2009
    Location
    St. Louis, MO
    Posts
    1,997

    Default

    Quote Originally Posted by Remkus View Post
    Take a look at the inside of Thematic. When activated it sports an activated widget or two..
    Have a look at Oenology, also. I added "default" Widgets (see, e.g. sidebar-right.php)

    Basically, you need to use the_widget():

    PHP Code:
    <?php if ( !dynamic_sidebar'sidebar-right' ) ) {

    $widgetsidebarrightargs = array(
        
    'before_widget' => '<div class="widget">',
        
    'after_widget' => '</div>',
        
    'before_title' => '<div class="title widgettitle">',
        
    'after_title' => '</div>'
    );

    the_widget('WP_Widget_Calendar' 'title=' $widgetsidebarrightargs );
    the_widget'oenology_widget_linkrollbycat' 'title=Oenology Links by Cat' $widgetsidebarrightargs );
    the_widget('WP_Widget_Meta' 'title=Meta' $widgetsidebarrightargs );

    ?>
    WP TurnKey - Turn-Key WordPress installation and maintenance services
    WordPress user since 2005 | @chip_bennett | chipbennett.net | cbnet Plugins

  4. #4
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,801

    Default

    I assumed jwack was looking to change the default widgets, ie: actually change the widgets in the admin panel, not just display some default widgets when none are present.

  5. #5
    jwack is offline Hello World
    Join Date
    Aug 2009
    Posts
    46

    Default

    I want to set the widgets that display by default when someone creates a new blog on my site. The newly created blog will use a child theme of twentyten. I will take a look over the above info and see if it gets me headed in the right direction. Thanks for the replies.

  6. #6
    chipbennett's Avatar
    chipbennett is offline WordPress Legend
    Join Date
    Feb 2009
    Location
    St. Louis, MO
    Posts
    1,997

    Default

    Quote Originally Posted by Ryan View Post
    I assumed jwack was looking to change the default widgets, ie: actually change the widgets in the admin panel, not just display some default widgets when none are present.
    Part of the problem is the terminology. "Default Widgets" != "Core" or "Standard" Widgets, but is often assumed to mean either.

    If I'm understanding the OP properly, he doesn't want to modify the WP_Widgets, but rather, wants to specify which Widgets display by default in the widgetized sidebar (i.e. unless/until the user places Widgets in the sidebar).
    WP TurnKey - Turn-Key WordPress installation and maintenance services
    WordPress user since 2005 | @chip_bennett | chipbennett.net | cbnet Plugins

  7. #7
    jwack is offline Hello World
    Join Date
    Aug 2009
    Posts
    46

    Default

    Sorry for the confusion, I was/am rather confused myself.

    Using the theme Twentyten (actually a child theme), when you first setup a blog it has 5 widgets already defined in the "Primary Widget Area" of the admin. I want to change these widgets so that when someone sets up a blog on my site they start out with 5 widgets that I set (the list of available widgets is fine as is). A couple of these widgets come from plugins and a couple are default widgets.

    I see in the TwentyTen theme > sidebar.php sets widgets, but these are only ever used if NO widgets are active in the admin.

    Hopefully that helps clear things up.

  8. #8
    chipbennett's Avatar
    chipbennett is offline WordPress Legend
    Join Date
    Feb 2009
    Location
    St. Louis, MO
    Posts
    1,997

    Default

    The Primary Widget area is pre-populated, within the Widgets UI? Or only on the front end?

    If the "Primary" Widget Area has no assigned Widgets in the Widgets UI, but you see Widgets on the front end (Search, Archives, Register, Login/out, Meta), then those are the ones you see defined in sidebar.php.

    TwentyTen isn't doing anything else to add or define Widgets that display by default. Either the Child Theme is doing something, or you're just picking up previously-assigned Widgets from a previous Theme with a sidebar named "Primary".
    WP TurnKey - Turn-Key WordPress installation and maintenance services
    WordPress user since 2005 | @chip_bennett | chipbennett.net | cbnet Plugins

  9. #9
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,801

    Default

    Quote Originally Posted by jwack View Post
    ... I want to change these widgets so that when someone sets up a blog on my site they start out with 5 widgets that I set (the list of available widgets is fine as is). A couple of these widgets come from plugins and a couple are default widgets.

    I see in the TwentyTen theme > sidebar.php sets widgets, but these are only ever used if NO widgets are active in the admin
    That's what I thought you meant originally.

    I assume you can set them in the option 'sidebar_widgets'.

    Try dumping it's content to see if there's anything useful in there:
    PHP Code:
    <?php var_dumpget_option'sidebars_widgets' ) ); ?>

    If you are going to go down this route, then I suggest using a unique ID for the widget area(s) so that you don't get clashes with other themes. I could imagine people being a bit grumpy if they change to your theme, then back to their original, but lose their widget setup in the process as you had modified automagically on them.

  10. #10
    jwack is offline Hello World
    Join Date
    Aug 2009
    Posts
    46

    Default

    Quote Originally Posted by chipbennett View Post
    The Primary Widget area is pre-populated, within the Widgets UI? Or only on the front end?

    If the "Primary" Widget Area has no assigned Widgets in the Widgets UI, but you see Widgets on the front end (Search, Archives, Register, Login/out, Meta), then those are the ones you see defined in sidebar.php.

    TwentyTen isn't doing anything else to add or define Widgets that display by default. Either the Child Theme is doing something, or you're just picking up previously-assigned Widgets from a previous Theme with a sidebar named "Primary".
    I have tested this a couple times. The Widget UI & front end are populated with (Search, Recent Posts, Recent Comments, Archives, Categories, Meta). This is true even with a new user on a new blog, with either twentyTen or the child as the theme. Sidebar.php only has (Search, Archives, Meta) which don't get displayed by default because the widget UI is already populated.


    Quote Originally Posted by Ryan View Post
    That's what I thought you meant originally.

    I assume you can set them in the option 'sidebar_widgets'.

    Try dumping it's content to see if there's anything useful in there:
    PHP Code:
    <?php var_dumpget_option'sidebars_widgets' ) ); ?>
    If you are going to go down this route, then I suggest using a unique ID for the widget area(s) so that you don't get clashes with other themes. I could imagine people being a bit grumpy if they change to your theme, then back to their original, but lose their widget setup in the process as you had modified automagically on them.
    This is the output from the var dump on a brandnew blog setup, with out changing any widgets or anything else.

    array(8) { ["wp_inactive_widgets"]=> array(0) { } ["primary-widget-area"]=> array(6) { [0]=> string(8) "search-2" [1]=> string(14) "recent-posts-2" [2]=> string(17) "recent-comments-2" [3]=> string(10) "archives-2" [4]=> string(12) "categories-2" [5]=> string(6) "meta-2" } ["secondary-widget-area"]=> array(0) { } ["first-footer-widget-area"]=> array(0) { } ["second-footer-widget-area"]=> array(0) { } ["third-footer-widget-area"]=> array(0) { } ["fourth-footer-widget-area"]=> array(0) { } ["array_version"]=> int(3) }

    I am not sure what you mean by "I assume you can set them in the option 'sidebar_widgets'."

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •