WordPress.org

Ready to get started?Download WordPress

Forums

Twenty Eleven - Remove "Posted by ..." (29 posts)

  1. minimatical
    Member
    Posted 2 years ago #

    Hi, I hope someone can help me!

    I use the theme "Twenty Eleven 1.2" and in any articles appear date and nickname! Example:
    "Posted on 30 october 2011 by minimatical"

    Date its ok, but I wanna remove "by minimatical" part.

    I try to delete some code in php page... but nothing! forum posts don't help me! =/
    oh can I remove it?

    Thank you!

  2. rachelbaker
    Member
    Posted 2 years ago #

    Can you tell us which file you already removed code from? And, if known, what code you removed?

  3. minimatical
    Member
    Posted 2 years ago #

    I have try to remove in "wp-app.php":

    $post_author = (int) $user_ID;

    and in "wp-content\themes\twentyeleven" in page functions.php

    I have try to remove:

    esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    sprintf( esc_attr__( 'View all posts by %s', 'twentyeleven' ), get_the_author() ),
    esc_html( get_the_author() )

    but nothing change!

  4. Marventus
    Member
    Posted 2 years ago #

    Hi all,

    Due to the way in which the Twenty Eleven theme is coded, if you modify the twentyeleven_posted_on function directly, those changes will be reflected in all theme files that use this function.
    If you are certain that you want to completely remove that info, here's the reworked function for you:

    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>', 'twentyeleven' ),
        esc_url( get_permalink() ),
        esc_attr( get_the_time() ),
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_date() ),
      );
    }

    Be careful not to delete the endif; command that comes after the closing curly bracket.

    Cheers!

  5. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Do not edit the Twenty Eleven theme. It is the default WordPress 3.2 theme and having access to an unedited version of the theme is vital when dealing with a range of site issues. Create a child theme for your changes. Once your child theme is active, we should be able to help with the customisation.

  6. Marventus
    Member
    Posted 2 years ago #

    Esmi has a point: I had automatically assumed a child theme was in place, but now re-reading the original post, I realized there is no mention of a child-theme.
    If you have already made too many changes to it, you could rename the theme folder, edit the commented out theme info inside style.css, and re-upload an unedited version of the original Twenty Eleven theme. That way you can keep both the original theme and your customized version.
    Cheers!

  7. Marventus
    Member
    Posted 2 years ago #

    Hi,

    Where you able to figure this out? Do you need additional assistance?
    Let us know.

    Thanks!

  8. minimatical
    Member
    Posted 2 years ago #

    Realy thank you for the Reply!!
    I have never create a Child Theme, so it is my first!

    so I have create a new folder:
    wp-content/themes/twentyeleven-child-theme
    and I have put in it two files:

    - style.css
    it's the same of "twentyeleven" just change the "Theme Name" in the code.

    - functions.php
    with that code in it:

    <?php
    
    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>', 'twentyeleven' ),
        esc_url( get_permalink() ),
        esc_attr( get_the_time() ),
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_date() ),
      );
    }
    
    ?>

    I don't know if it is the right procedure... for now nothing change in my website! =P

    P.S.
    Sorry for my bad english

  9. Marventus
    Member
    Posted 2 years ago #

    Hi,

    The problem with your approach is that your child theme is still using your original themes' functions, including the original twentyeleven_posted_on. Even if you renamed your custom function, it would not work, because the template files would still be calling the original function's name.

    I also don't think it's possible to modify the output of the original function, since it has no hooks you could use (Esmi, please correct me here if I'm wrong).

    I think the easiest solution would be to keep your modified TwentyEleven theme in a different folder inside themes, assign it a different name in the style.css file, and make all the changes you need directly. To rename the theme, try to locate this text at the beginning of that file style.css file:

    /*
    Theme Name: Twenty Eleven

    Change it to Twenty Eleven (custom) so you can individualize it in the Admin Panel.

    Of course, it is advisable as Esmi said to keep the original TwentyEleven theme unmodified so that you can reference it if you encounter any problems.

  10. minimatical
    Member
    Posted 2 years ago #

    Now in my wp-content/themes I have this folders:

    - "twentyeleven" (with all the original files)
    - "twentyeleven-child-theme" (my new-custom folder).

    In this folder I have put 5 files:
    style.css its equal to the original but I have just change that:

    /*
    Theme Name: Twenty Eleven (Child Theme)

    and I have change the same line also in this files: editor-style.css, editor-style-rtl.css and rtl.css.

    and in functions.php I have just put your code:

    <?php
    
    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>', 'twentyeleven' ),
        esc_url( get_permalink() ),
        esc_attr( get_the_time() ),
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_date() ),
      );
    }
    
    ?>

    I have clean my cache browser and go in admin pannel, but I can't see my custom theme. Just "Twenty Eleven 1.2" (the original) like default.

  11. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    style.css its equal to the original but I have just change that:

    /*
    Theme Name: Twenty Eleven (Child Theme)

    you need to change more than that; - see http://codex.wordpress.org/Child_Themes#The_required_style.css_file

    particularly, you need to have this line:

    Template:       twentyeleven
  12. minimatical
    Member
    Posted 2 years ago #

    Thank you alchymyth !
    I have add this line in style.css:
    Template: twentyeleven
    and now I can see my custom theme in admin pannel!

    But...when I going to active it... all my website go in crash!
    and give me this message:

    Parse error: syntax error, unexpected ')' in /web/htdocs/www.mywebsite.com/home/wp-content/themes/twentyeleven-child-theme/functions.php on line 9

  13. minimatical
    Member
    Posted 2 years ago #

    So it is something wrong in my functions.php

  14. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    there is a comma too much in the code, at the end of this line esc_html( get_the_date() ), - the comma needs to be removed;

    corrected:

    <?php
    
    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>', 'twentyeleven' ),
        esc_url( get_permalink() ),
        esc_attr( get_the_time() ),
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_date() )
      );
    }
    
    ?>
  15. Marventus
    Member
    Posted 2 years ago #

    Oops, that was my bad,

    I was moving the arguments around and left an extra comma in the code.
    The corrected version should work.

    Sorry about that!

  16. minimatical
    Member
    Posted 2 years ago #

    Oh yesss!!! now all working good!!
    Realy thank you!!! have a good day

  17. minimatical
    Member
    Posted 2 years ago #

    Oh, that was ok in Home page. But when I open a single article, in his footer I can read:

    This entry was posted in xxxxx by yyyyy

    So I have find this in content-featured.php
    and content-single.php
    so I have deleted:
    by <a href="%6$s">%5$s</a>
    (and I also have translate in my language)

    so I have put this two files in "twentyeleven-child-theme" folder, and now its ok!

  18. lurambler
    Member
    Posted 2 years ago #

    After lots of messing around and trying different things, this is what finally helped me.

    Edit the style.css of your child theme by adding the following line at the bottom

    .entry-meta{display:none;}

    That was it.

  19. cherry0
    Member
    Posted 1 year ago #

    Hey guys, thanks for your input I've been looking for a solution to this for a while. However it seems to break the backend of my site.

    @ alchymyth - When I put the following code into my twenty eleven Child Theme's functions.php file, it breaks my site.

    After adding the code, the site functions okay from the front end and it does remove the 'Posted By AuthorName', BUT when I try to access the back end login area I just see a white screen.

    I put the following code into my child theme's functions.php file:

    <?php
    if ( ! function_exists( 'twentyeleven_posted_on' ) ) :
    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>', 'twentyeleven' ),
        esc_url( get_permalink() ),
        esc_attr( get_the_time() ),
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_date() )
      );
    }
    endif;
    ?>

    Am I doing something wrong here? I tried removing the 'If' statements but I get the same issue of not being able to access the login area.

  20. Marventus
    Member
    Posted 1 year ago #

    Hi.
    Perhaps the function is also targeting the admin section. Try to change the beginning of your if statement to this:

    if ( ! function_exists( 'twentyeleven_posted_on' ) && ! is_admin() ) :
  21. Digital Raindrops
    Member
    Posted 1 year ago #

    The code is fine and should work.

    Try this:
    Remove the last ?> and leave the php tag open!

    HTH

    David

  22. cherry0
    Member
    Posted 1 year ago #

    Thanks for the tips guys, I managed to get it working.

    @ Digital Raindrops - I tried removing the last ?> but it didn't have any effect, so I tried something similar.

    My child functions.php file was like this:

    <php
       // I had custom code here already
    ?>
    <php
       // I had the code here mentioned in my first post
    ?>

    I simply got rid of the two seperate opening and closing php tags, and
    made it as one, e.g.

    <php
       // ccustom code here already
       // code here mentioned in my first post
    ?>
  23. Marventus
    Member
    Posted 1 year ago #

    Thanks for the tips guys, I managed to get it working.

    You are welcome, and I'm glad you were able to figure it out.
    Please don't forget to mark this thread as resolved whenever you get a chance.
    Thanks!

  24. cherry0
    Member
    Posted 1 year ago #

    Hi Marventus, I'm new to the forum and am not sure how to mark this thread as resolved. I'm just trying to work out how to do that, if you can let me know that would be great.

    Update: I think the reason why I can't mark it as resolved is because I didn't start the thread, is that right?

  25. Marventus
    Member
    Posted 1 year ago #

    @cherry0: Yes, that is correct. I forgot it wasn't you who started the thread: sorry about that! ;-)
    In case you want to know how to do it for other threads you open, the option appears as a dropdown box on the right side of the thread with the title "This topic is".

    @minimatical: could you do the honors whenever you can?
    Thanks!

  26. jadermeister
    Member
    Posted 1 year ago #

    hello, i have a question,
    I followed this threads advice to hide the posted on date on my posts as well, only now i am getting this:
    Parse error: syntax error, unexpected $end in /home/jadelor/domains/canelaevents.nl/public_html/wp-content/themes/twentyeleven/functions.php on line 583

    Can any one help me? I am very inexperienced at HTML so i dont really know what to look for.

    Any help is apreciated!!

    http://www.canelaevents.nl

    CHEERS!!
    JADE

  27. Marventus
    Member
    Posted 1 year ago #

    Hi jadermeister,

    You seem to be missing a curly bracket { or have one two many in your functions.php file. Also, check to see if your opening (<?php) and closing (?>) PHP tags are properly placed.
    If you still can't figure it out, try creating a paste of your functions.php code in Pastebin so that we can take a look at it.

    Cheers!

  28. kimaldis
    Member
    Posted 1 year ago #

    In the child theme's style.css add this code:

    .post .entry-utility, .post .entry-meta {display:none;}

    this works in the twenty ten theme too. Probably works in most themes.

  29. Arntard
    Member
    Posted 1 year ago #

    I had a similar problem. I wanted to remove the "Posted on".

    I copied the twentyeleven_posted_on() function to my child functions.php and removed the "posted on"-part. <- Here is where you remove what you want.
    Then renamed it to custom_posted_on().

    Finally edited the content.php and content-single.php to contain the custom_posted_on.
    <?php if ( 'post' == get_post_type() ) : ?>
    <div class="entry-meta">
    <?php custom_posted_on(); ?>
    </div><!-- .entry-meta -->
    <?php endif; ?>

    It might help.

Topic Closed

This topic has been closed to new replies.

About this Topic