• Hello!

    Well, I’m trying to change some piece of PHP code, but I’m having some problems. I’m trying to change the “home” link to something else basically. This is the piece of code, found in functions.php:

    function twentytwelve_page_menu_args( $args ) {
    	if ( ! isset( $args['show_home'] ) )
    		$args['show_home'] = true;
    	return $args;
    }

    I am trying to do it the correct way, so I created another functions.php file in my child theme, and I pasted the code above in there (with <?php and ?> at the beginning and at the end of the file). But sadly, it won’t work… all pages turn blank.

    I’ve tried it with a different code, the one found under this page under the functions.php paragraph. I used the piece of code for the favicon to test it, and it worked — I have a favicon now.

    Why does the other one not work? I first supposed it is because the piece of code for the favicon isn’t found in functions.php in the first place, and so they don’t “clash”, but I thought you should’t modify any of the parent themes?

    All help much appreciated 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • Please enable WP_DEBUG, and report the fatal error you’re getting.

    Also, please post relevant code from your child Theme functions.php.

    My guess, though, is that you’ve named the function in the child Theme the same as the function in the parent Theme.

    Thread Starter Foliferous

    (@revs)

    Oh, I didn’t know they shouldn’t have the same name.

    I renamed the function into something else, it still doesn’t work but I have no error anymore and the page appears normally now!

    Here’s my child theme code:

    <?php
    
    // ———— FAVICON ———— 
    
    function favicon_link() {
        echo '<link rel="shortcut icon" type="image/x-icon" href="icons/favicon.png" />' . "\n";
    }
    add_action( 'wp_head', 'favicon_link' );
    
    // ———— STARTSEITEN LINK ———— 
    
    function sommer2013_page_menu_args( $args ) {
    	if ( ! isset( $args['show_home'] ) )
    		$args['show_home'] = Startseite;
    	return $args;
    }
    
    ?>

    Where you see “Startseite”, this is meant to replace “Home” on the main page. I’ve found this way of doing it somewhere on here. It worked fine when I was changing that in function.php of the parent theme.

    Thread Starter Foliferous

    (@revs)

    SORRY! It works 🙂

    I forgot a piece of code… thanks for the help, that was the solution! I need to rename them into something different!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Modify PHP in child theme?’ is closed to new replies.