WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Child functions.php not overwriting parent (4 posts)

  1. Big Hungry Geek
    Member
    Posted 1 year ago #

    Trying to modify the twentyeleven_posted_on() function using a child theme. Searched through a dozen identical topics and followed a myriad of tips to no avail, so I'm sorry if I'm being super redundant.

    Steps taken:

    1. Created a new directory called /wp-content/themes/twentyeleven-child
    2. Uploaded a blank style.css to /twentyeleven-child
    3. Uploaded a blank functions.php to /twentyeleven-child
    4. Added required header & import information to the new style.css
    5. Copied entire twentyeleven_posted_on() function into the new functions.php, changing only "Posted on" to "Published on" just to test it out, but my site still displays "Posted on."

    Entire contents of /twentyeleven-child/style.css

    /*
    Theme Name: Twenty Eleven Child
    Author: Big Hungry Geek
    Author URI: http://bighungrygeek.com/
    Description: Child theme for the twenty eleven theme.
    Version: 1.0
    License: GNU General Public License v2 or later
    License URI: http://www.gnu.org/licenses/gpl-2.0.html
    Template: twentyeleven
    */
    
    @import url("../twentyeleven/style.css");
    @import url("../twentyeleven/editor-style-rtl.css");
    @import url("../twentyeleven/editor-style.css");
    @import url("../twentyeleven/rtl.css");

    Entire contents of /twentyeleven-child/functions.php

    <?php
    
    function twentyeleven_posted_on() {
    	printf( __( '<span class="sep">Published on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven' ),
    		esc_url( get_permalink() ),
    		esc_attr( get_the_time() ),
    		esc_attr( get_the_date( 'c' ) ),
    		esc_html( get_the_date() ),
    		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    		esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) ),
    		get_the_author()
    	);
    }

    I copied the function exactly from the parent to the child, and I only changed "Posted on" to "Published on," but my site still displays "Posted on." Am I overlooking something that should be obvious that's preventing the child function from properly overwriting the parent? I know this function in the parent has if ( ! function_exists( 'twentyeleven_posted_on' ) ) :, so I should be OK? Any help would be very much appreciated!

  2. Did you activate the child theme in Appearance > Themes?

  3. Big Hungry Geek
    Member
    Posted 1 year ago #

    :-\

    Thanks!

  4. You're welcome! I'm glad it turned out to be something simple!

Topic Closed

This topic has been closed to new replies.

About this Topic