WordPress.org

Support

Support » Themes and Templates » [Resolved] help changing words "Posted on" and "by"

[Resolved] help changing words "Posted on" and "by"

  • Hi, someone created a child theme for me and has now vanished.
    I’m beginning to do things on my own. I’ve managed to do several things but have spent the last two hours trying to change the text “Posted on” and “by” with words in Spanish, but failed (had to override the child them twice already ’cause I messed up).

    Could anyone tell me precisely what code to copy and where?
    I’ve tried editing functions.php but must have done it wrong (twice)
    It’s a Twenty Eleven child them.

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael

    @alchymyth

    Forum Moderator

    look into functions.php in the function twentyeleven_posted_on()

    you can copy the full function from the parent theme into the child theme’s functions.php, and then edit it there.

    http://codex.wordpress.org/Child_Themes#Using_functions.php

    have you considered to use the Spanish language files ?
    http://wordpress.org/support/topic/theme-twenty-eleven-translation?replies=6#post-2519485

    Thanks alchymyth; the weird thing is I have wordpress in Spanish, but “posted on” and “by” still show in English.

    This is what I see now in the child theme’s functions.php file

    <?php
    	define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyeleven_header_image_width', 1000 ) );
    	define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyeleven_header_image_height', 130 ) );
    ?>

    And this is what I think is the posted_on function I have to paste and modify.

    function twentyeleven_posted_on() {
    	printf( __( '<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a 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()
    	);

    [some of your above code is displayed broken because it was posted unmarked; see forum guidelines for posting code: http://codex.wordpress.org/Forum_Welcome#Posting_Code ]

    I put it right above ?>

    and when I save it, everything goes crazy and I have to override the child them. What am I doing wrong? (probably obvious, bu… ).

    Michael

    @alchymyth

    Forum Moderator

    the function needs to end with its }

    general structure:

    function whatever() {
    //some code here
    }

    – so this is what you could paste into functions.php into the line before the last ?>:

    function twentyeleven_posted_on() {
    	printf( __( '<span class="sep">Posted 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()
    	);
    }

    Oh, no wonder.

    Thanks, I just tried modifying it right in Twenty Eleven (I know is not the best way) and it worked. I’ll leave it like that for the moment since I’m considering changing to Twenty Twelve.

    All the best.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] help changing words "Posted on" and "by"’ is closed to new replies.
Skip to toolbar