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!!!
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; ?>
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?
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
);
Jesus keesiemeijer I would not able to do this even in 100 years, thanks A LOT my friend thank you!!!!!!!
No problem. Gad you got it resolved.
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!