WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] help changing words "Posted on" and "by" (5 posts)

  1. joseerre
    Member
    Posted 1 year ago #

    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.

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    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

  3. joseerre
    Member
    Posted 1 year ago #

    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... ).

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    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()
    	);
    }
  5. joseerre
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic