lgreer0010
Member
Posted 8 months ago #
This seems to be a very tough subject. I keep searching and searching but don't know what I need to do to fix my problem. I now know that when your theme is updated (I am using Constructor) that it can wipe out all your hard work. So I thought I'd give child themes a try. Well everything is great until I try to copy over the dreaded functions.php. My dilemma is that if I ever have to up date again the widgets that I have made which are in the functions.php will be wiped out as well and I'll have to add those all over again. So, how do I create a functions.php so I don't have to worry about losing the widgets that I have created? Here are the widget codes for my theme (the ones toward the very end are the ones I use to control the parent theme. Where To Go is one I have created.):
[code moderated - please follow http://codex.wordpress.org/Forum_Welcome#Posting_Code when posting code]
until I try to copy over the dreaded functions.php
Never copy the functions.php file from the parent into the child. You have to create a new functions.php file in the child theme.
lgreer0010
Member
Posted 8 months ago #
And I understand that esmi but I guess that's just it. I don't know how to start a new functions.php. I've come across some codes online but don't know what I should start it off with. Should I start it off with a widgets code? I tried to put a code in for a new widget but it did not display under with my other widgets.
Thanks for answering me.
Your child theme's functions.php should only be thing's you've added. So, create a new text file and cut/paste anything you've added to your theme's functions.php between an opening <?php and a closing ?>. Make sure there is absolutely no extra whitespace after the ?>. Then save it as functions.php and upload it to your child theme.
You might have already read it, but this explains things fairly well:
http://codex.wordpress.org/Child_Themes#Using_functions.php
lgreer0010
Member
Posted 7 months ago #
Figured it out! Thanks guys!
lgreer0010
Member
Posted 7 months ago #
This is what my code looked like for my Constructor theme for those having the same probs.
<?php
if (!function_exists('register_sidebar')) {
// options for all follows sidebars
$widget_options = array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>',
);
register_sidebar(array_merge($widget_options, array('id'=>'sidebar-pages5', 'name'=>'Home')));
}
sidebar5 and Home are what I added and what you would change to fit your own widgets.
lgreer0010
Member
Posted 7 months ago #
Somehow I thought the above worked. It's actually this:
<?php
// options for all follows sidebars
if (function_exists('register_sidebar')) {
$widget_options = array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>',
);
register_sidebar(array_merge($widget_options, array('id'=>'extra1','name'=>'Home')));
}
The 'extra1' should go in numerical order 'extra2' and so forth and replace 'Home' with your own name of widget.