WordPress.org

Ready to get started?Download WordPress

Forums

Nishita
child themes and nishita's functions.php (8 posts)

  1. softobjects
    Member
    Posted 2 years ago #

    Nishita's functions.php contains the following comment:

    "To override nishita_setup() in a child theme, add your own nishita_setup to your child theme's functions.php file."

    My initial act was to copy nishita's functions.php to the child theme's folder. This gave me errors related to two functions. Here's one of the errors. Commenting that function out reveals the other function's re-declaration error. After that there are two other errors related to the calls to the two commented-out functions:

    Fatal error: Cannot redeclare nishita_calendar_widget_title() (previously declared in [child-theme's-path]/wp-content/themes/[child-theme]/functions.php:225) in [nishita-theme's-path]/wp-content/themes/nishita/functions.php on line 230

    What is the practice to keep nishita's functions.php as-is (for incremental tweaking) and still avoid this error?

    Thanks!

    http://wordpress.org/extend/themes/nishita/

  2. peredur
    Member
    Posted 2 years ago #

    Do just as it says. You don't need to copy anything from your parent theme's functions.php file. Just include in it the function definition(s) you want to add or overwrite.

    Child themes load both the parent's template files, CSS files and functions.php file and the child's template files, CSS files and functions.php file.

    Unlike template and CSS files, though, which are loaded **after** parent theme's template and CSS files, a child theme's functions.php file is loaded **before** the parent theme's functions.php file. Therefore, as long as the overwritten function in the parent is defined like this:

    if ( ! function_exist( function_name ) ) {
      function ( function_name ) {
        // body of the function...
      }
    }

    ... everything should be fine. Your function will be loaded and the original---because function_exists() returns TRUE---will be ignored.

    It is possible that, in your theme, not every function in functions.php in the parent is defined in this way. Therefore if you copy your parent's functions.php file into your child, those functions not protected in the way described will already have been defined in your child theme when the parent's functions.php loads, giving the error you see.

    So just get rid of everything in your child theme's functions.php file except for those functions you are adding or overwriting. You might also want to check in your parent theme's functions.php file that the functions you are trying to overwrite are protected as described, but it would appear that you are safe with the one you mention (nishita_setup()) since the documentation specifically invites you to overwrite it.

    HTH

    PAE

  3. softobjects
    Member
    Posted 2 years ago #

    Thank you so much for explaining this in such detail!

    Cheers,
    sO

  4. thomasktownsend
    Member
    Posted 2 years ago #

    In Nishita, under my main header photo, there's the word "about" by itself. Where do I go to delete that? Is it supposed to be there? Or is it a partial caption to my photo? I don't see where to delete it.

    Thanks,

    Tom

  5. peredur
    Member
    Posted 2 years ago #

    Please start another thread. This helps other people when they search the list for answers.

    When you post your new topic, please include a link to your site so that we can see what's going on.

    Cheers

    PAE

  6. thomasktownsend
    Member
    Posted 2 years ago #

    Good point -- the site is

    http://iwillfindbeauty.com/

    Thanks.

  7. softobjects
    Member
    Posted 2 years ago #

    @thomasktownsend wrote:

    In Nishita, under my main header photo, there's the word "about" by itself. Where do I go to delete that? Is it supposed to be there? Or is it a partial caption to my photo? I don't see where to delete it.

    peredur wants you to start a new thread about this issue as this thread is about the theme's functions.php file.

    The "ABOUT" you are seeing is the menu item belonging to the sample "Page" (as opposed to a "Post") that comes with every theme. You can edit it (or delete it) by visiting "Pages" from the Dashboard. Every page you add there becomes a menu item.

  8. thomasktownsend
    Member
    Posted 2 years ago #

    Excellent! Found it.Thanks so much.

    Tom

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic