WordPress.org

Ready to get started?Download WordPress

Forums

Error in functions.php while making childtheme from edited parent (3 posts)

  1. CobiVV
    Member
    Posted 3 years ago #

    Hello people,

    Old situation: Made alterations directly to the twentytentheme

    Desired new situation: a working childtheme, everything working/looking exactly like I made the altered twentytentheme

    Since I had edited not only style.css but also header.php and other files in my parent-theme, I copied all of the files in themes/twentyten to my new child themefolder themes/twentytencobi. In style.css in my child theme I changed the header acoording to a tutorial, this style.css seems to wotk fine.

    But: when I activate my childtheme, the following error-message appears:

    Fatal error: Cannot redeclare twentyten_page_menu_args() (previously declared in /public/sites/www.verzameldewerken.cc/wp-content/themes/twentytencobi/functions.php:214) in /public/sites/www.verzameldewerken.cc/wp-content/themes/twentyten/functions.php on line 217

    As I have searched/googled for answers, I now have a slight idea of what is causing this error, but no idea as to how to resolve it in my specific case. So, I was hoping maybe one of you could help me out?

    The code in functions.php in both parent- and child-theme are at this point as follows: http://pastebin.com/embed_js.php?i=WyFC7gum

    my website is here: http://www.verzameldewerken.cc/ (now back to "old", directly edited twentytentheme).

  2. jonradio
    Member
    Posted 3 years ago #

    The Theme Gurus are more likely to be looking here:
    http://wordpress.org/support/forum/themes-and-templates

    So, if you don't get an answer in the next couple of hours, I would re-post there.

  3. alchymyth
    Forum Moderator
    Posted 3 years ago #

    @adiant:
    i wouldn't.
    double posting or bumping does not get you any more responses than sticking with your one thread.

    functions.php is the one template file that cannot be copied fully into a child theme.

    in functions.php of twenty ten, there are some functions, that are preceded by a line of code, for instance: if ( ! function_exists( 'twentyten_setup' ) ):
    with these, you can re-define/re-use the function (name) in your child theme.

    other functions as the one that created your error message,
    (for instance: function twentyten_page_menu_args( $args ) { )
    are directly defined just for the parent theme, and cannot be re-used in the child theme.
    this particular function is used in a filter, and you can define a new function in the child theme to influence the filter, if you need.

    so, if you have modified functions.php of the twenty ten before creating the child theme, you have to check carefully how you can transport these changes into your child theme so that your child theme works the same way as your modified twenty ten (even after the wtenty ten is replaced with a fresh copy).

Topic Closed

This topic has been closed to new replies.

About this Topic