WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How Do You Properly Create Child Theme? (3 posts)

  1. rixtertrader
    Member
    Posted 1 year ago #

    I needed to add two functions to functions.php for my site in order to remove the WP logo and the PRIVATE string from private pages.

    Because I've read that I should not tinker with the 'core' files in case of 'updating', etc., I went the CHILD THEME route.

    According to the instructions, I created a new subdirectory under /themes called /twentyten-child.

    In this subdirectory, I added a style.css file with the header info:

    /*
    Theme Name: Twenty Ten Child
    Description: Child theme for the Twenty Ten theme
    Author: Rixter
    Template: twentyten
    */

    @import url("../twentyten/style.css");

    Nothing else in this file. No changes to styles, etc.

    Then I added a functions.php file into the child theme directory. This is all that it has in it.

    <?php

    // Rick's attempt to filtering out PRIVATE
    function remove_private_prefix($title) {
    $title = str_replace(
    'Private:',
    '',
    $title);
    return $title;
    }
    add_filter('the_title','remove_private_prefix');

    /* Rick added this code to remove WP logo menu items */
    add_action( 'admin_bar_menu', 'remove_wp_logo', 999 );

    function remove_wp_logo( $wp_admin_bar ) {
    $wp_admin_bar->remove_node('wp-logo');
    }

    ?>

    Then in my DASHBOARD under THEMES, I choose my Twentyten-Child theme.

    Well, my modifications worked just fine! I was thrilled! My first attempt at this. Woo hoo!

    But then, I noticed that when I try to create a POST and click on UPDATE, my page goes blank. I have to go to my sites URL to get back into the DASHBOARD.

    What did I miss? Was there something else I have to add to my child theme directory so that everything else works as before?

    I assumed that everything in the original Twentyten theme should work as before, except I've added two new functions.

    Help please.

    Thanks in advance.

  2. vtxyzzy
    Member
    Posted 1 year ago #

    Are you sure it is the functions causing the problem? Does everything work if you remove the code in functions.php?

  3. rixtertrader
    Member
    Posted 1 year ago #

    Yes, everything works when the functions.php file is deleted.

    The problem, as it turns out, is that you cannot have any blank lines at the end of the functions.php file. This apparently confuses the redirect, resulting in the blank page.

    It's working now, and I've been able to put my functions back in the file (without blank lines follwing the last code line).

    Works good.

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic