How to Change Author name

Discussion in 'NomNom Theme' started by stergos, Feb 14, 2012.

  1. stergos Member

    Hi, I would like to have the ability to change the author name in index and post page.


    Before a few months I done it with the help of Wp support here but that will only change the author name at the end of a post not to the top too. This is an example of one of my posts as you see to the top below the title "Posted on February 5, 2012 by admin" but to the end of the post "This entry was posted in Articles by Tristian r Carr. Bookmark the permalink. "

    I am using custom fields to change the name of the second section (customauthor and customauthorlink), is there any way to change and the first one?

    I guess responsible for that is this code in content-single.php
    Code:
            <div class="entry-meta">
                <?php twentyeleven_posted_on(); ?>
            </div><!-- .entry-meta -->
    But I'm not sure what I need to do with that...

    Thanks in advance!
  2. Zeaks Author

    Do you want to change the top or bottom author link on single? Also, why do you need to links to the same author on the same page? Would it not be better to just show 1?
  3. stergos Member

    Sure I would like to use only the top. I don't know why I have 2 sections...

    I thought NomNom is add the second section on bottom, so how can I remove the second at the bottom on single page and how to add custom author to the first one on single page and index?

    Thanks mate!
  4. stergos Member

    No ideas? Anyone please?
  5. Zeaks Author

    You'll have to copy content-single.php from Twenty Eleven to NomNom's directory. Lines 39-54 of content-single.php contain the lower meta info. You should be able to remove it from there.

    You can then use whatever code you used for the custom fields in the area you posted above in your first post.
    Couldn't you just change your name on the site?
  6. stergos Member

    Hey mate, thank you for response. I already have this file into NomNom directory, the changes I made to get custom author in the bottom is this code:
    Code:
    printf(
    $utility_text,
    $categories_list,
    $tag_list,
    esc_url( get_permalink() ),
    the_title_attribute( 'echo=0' ),
    get_the_author(),
    esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) )
    );
    To this:
    Code:
    $author = get_post_meta($post->ID, 'customauthor', true);
    $authorlink = get_post_meta($post->ID, 'customauthorlink', true);
    $author = ($author != '') ? $author : get_the_author();
    $authorlink = ($authorlink != '') ? $authorlink  : esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) );
    printf(
    $utility_text,
    $categories_list,
    $tag_list,
    esc_url( get_permalink() ),
    the_title_attribute( 'echo=0' ),
    $author,
    $authorlink
    );
    With a few words to remove the bottom author I guess is the second code.
    Well I will try it but where and how I make the first author name and link work?

    No I try it, it's not working.
  7. stergos Member

    Okay I remove the bottom author entry now I have to edit the first one to work with custom fields. I think I have to edit some how this code into functions.php:
    Code:
    if ( ! function_exists( 'twentyeleven_posted_on' ) ) :
    /**
    * Prints HTML with meta information for the current post-date/time and author.
    * Create your own twentyeleven_posted_on to override in a child theme
    *
    * @since Twenty Eleven 1.0
    */
    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()
        );
    }
    endif;
  8. Zeaks Author

    Stergos, I know I've mentioned this but, how did you try to change the author name? On the post editor page, there is an option for this (you might need to enable it under screen options at the top) See this image
    author.JPG
  9. stergos Member

    I have enable author link from screen options but is not what I need. This is show me only authors from my members. I need to edit the name and the link of authors which is not members to my site. For example the author of this article ( Mahesh thakur) is not member to my site, I add his name and link using custom fields "customauthor" and "customauthorlink".

    That's why I must change the code in functions.php some how to working like the author name in the bottom...
    "This entry was posted in"...
  10. stergos Member

    Well I make it work but it will only change the name and not the url.
    There is must be some similar code to get the url too, any ideas would be appreciated thanks.
  11. stergos Member

    Problem solved, thanks ;)

Share This Page