creating functions.php in child theme

Discussion in 'WordPress' started by sixrfan, Sep 13, 2010.

  1. #1
    i want to make some modifications to one of the functions in the Twenty Ten functions.php file. so i added a functions.php file (see code below) to my child folder. but now my site doesnt work.

    I get an error message that says ""Parse error: syntax error, unexpected T_ENDIF in /home/content/p/o/o/html/green/wordpress/wp-content/themes/twentytenchild/functions.php on line 48". Any idea what's wrong???

    
    
    <?php
    
    
    
    /** Tell WordPress to run child_theme_setup()
    
    when the 'after_setup_theme' hook is run.
    
    */
    
    add_action( 'after_setup_theme', 'child_theme_setup' );
    
    
    
    /** This function will hold our new calls and over-rides */
    
    if ( !function_exists( 'child_theme_setup' ) ):
    
    function child_theme_setup() {
    
    
    
        /*
    
        I want the Posted On date to show, but not the author.
    
        */
    
    
    
    function twentyten_posted_on() {
    
    
    
            printf( __( '<span class="%1$s">Posted on</span> %2$s', 'twentyten' ),
    
    
    
                    'meta-prep meta-prep-author',
    
    
    
                    sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
    
    
    
                            get_permalink(),
    
    
    
                            esc_attr( get_the_time() ),
    
    
    
                            get_the_date()
    
    
    
                    ),
    
    
    
                    sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
    
    
    
                            get_author_posts_url( get_the_author_meta( 'ID' ) ),
    
    
    
                            sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
    
    
    
                            get_the_author()
    
    
    
                    )
    
    
    
            );
    
    
    
    }
    
    endif; ?>
    
    
    
    PHP:
     
    sixrfan, Sep 13, 2010 IP
  2. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #2
    Hi, seems you forgot } for the end of the function:

     
    koko5, Sep 13, 2010 IP
    mcfox likes this.
  3. sixrfan

    sixrfan Well-Known Member

    Messages:
    354
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    thanks. that kind of helps, as my site now appears, but on my login.php i get this message which cant be good:

    "Warning: Cannot modify header information - headers already sent by (output started at /home/content/p/o/o/poolteesguy/html/green/wordpress/wp-content/themes/twentytenchild/functions.php:1) in /home/content/p/o/o/poolteesguy/html/green/wordpress/wp-login.php on line 337

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/p/o/o/poolteesguy/html/green/wordpress/wp-content/themes/twentytenchild/functions.php:1) in /home/content/p/o/o/poolteesguy/html/green/wordpress/wp-login.php on line 349"

    there must be something else i need to fix with the functions.php file. any idea what it is??? by the way, this is the site i'm working on: http://www.greenrefurbishing.com/wordpress
     
    Last edited: Sep 13, 2010
    sixrfan, Sep 13, 2010 IP
  4. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #4
    Hmm, as I saw your link, it seems you've utf files saved with bom. Try saving all files you've created or edited without BOM

    Hope this will solve the problem.
    Regards
    p.s.: All good php editors have such option.
     
    koko5, Sep 13, 2010 IP
  5. sixrfan

    sixrfan Well-Known Member

    Messages:
    354
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #5
    i'm very lost now. FYI, I'm a php newbie trying to re-create a functions.php file that works properly. i put the code into notepad++ but i'm not sure what i'm looking at or what to look for. please advise. thanks!
     
    sixrfan, Sep 13, 2010 IP
  6. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #6
    When you open your functions.php via command line text editor (edit.exe) you can see the byte order mark (BOM) at the beginning of the file:
    Start->run->cmd->edit functions.php

    remove BOM, save and exit edit.exe: this is the hard way. The Idea is to see visually the BOM in your functions.php file.

    Check Notepad++ options how to save files without bom.
    Also when functions.php is opened, check it's properties.

    BOM stays on top of the file and causes echoing these bytes order mark, so headers was sent-echo started at line 1...
    Please check the links or search again in Google about this problem.
    I'm not using notepad++ but as I see there are many plugins for this : as you can see they are ANSI and ANSI/Unicode compatible - to prevent BOM you should use ANSI/Unicode compatible plugins.
     
    koko5, Sep 13, 2010 IP