• Resolved Stergos

    (@stergos)


    Hi, i’m using twenty eleven theme (child) and i am trying to change the author name and link from a post by using custom fields. I create 2 new custom fields with the name “customauthor” and “customauthorlink” but the author name and link is not change the name is still remain admin. I guess i need to place a code to some .php file, can anyone give me some advice please? Thank you so much!

    Post link: http://www.e-hacking.com/articles/hacking-wii/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Stergos

    (@stergos)

    After a lot of search i find out that i need a lot things to do but i don’t have any idea how. I try to add <?php the_meta(); ?> to single.php but this just place as a text customauthor and customauthorlink to the end of the page. I want to replace “admin” with a new author and link.

    Please if someone has any idea what i need to do just reply, thank you!!!

    Moderator keesiemeijer

    (@keesiemeijer)

    Try it with this insite the loop [untested]:

    <?php
    $author = get_post_meta($post->ID, 'customauthor', true);
    $authorlink = get_post_meta($post->ID, 'customauthorlink', true);
    if($author != '' && $authorlink != '') :
    ?>
    <a href="<?php echo $authorlink; ?>"><?php echo $author; ?></a>
    <?php endif; ?>

    Thread Starter Stergos

    (@stergos)

    Hey keesiemeijer, thanks for reply! Inside the loop i guess you mean “loop.php” which is not exist to twenty eleven theme! Anywhere else i can place it?

    Moderator keesiemeijer

    (@keesiemeijer)

    Ok forget that code.

    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.

    in your child theme content-single.php change this:

    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:

    $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
    );

    Thread Starter Stergos

    (@stergos)

    Jesus keesiemeijer I would not able to do this even in 100 years, thanks A LOT my friend thank you!!!!!!!

    Moderator keesiemeijer

    (@keesiemeijer)

    No problem. Gad you got it resolved.

    Thread Starter Stergos

    (@stergos)

    Hey mate, the previous code is help me to change the author name to the bottom of the page “This entry was posted in Articles by Barbara. Bookmark the permalink. ” but there is also this “Posted on February 4, 2012 by admin ” to the top of the page below the title, is there any way to show “Barbara” like to the bottom? This is my link to see that online, Thanks a lot!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Custom fields problem’ is closed to new replies.