Support » Plugins » the_author displays twice

  • Resolved wonkotsane


    I have some bizarre behaviour displaying itself on my blog.

    I tinkered with the template so that if I add a meta with the name “Mood” it will display text saying what mood I was in. Initially I just hardcoded my name but today I wanted to change it so that it picks up the author name instead. On the single post this works fine but on the main index template it displays the author name twice.

    Here’s the code from index.php:

    Posted in <?php the_category(', ') ?> by: <?php the_author() ?><?php edit_post_link('Edit',' ',''); ?> <br/> <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?>
    	$mymood=get_post_meta($post->ID, "Mood", $single=true);
    		echo "<br /><span>".the_author()." was <strong>".get_post_meta($post->ID, "Mood", $single=true)."</strong> when he wrote this post</span><br />";

    What I get is:

    1 Commentwonkotsane
    wonkotsane was trying to remember when things started turning so shit when he wrote this post

    The html it generates is:

    Posted in <a href="" title="View all posts in General" rel="category tag">General</a> by: wonkotsane <a href=";post=848">Edit</a> <br/> <a href="" title="Comment on I would say this takes the biscuit but …">1 Comment</a>wonkotsane<br /><span>wonkotsane was <strong>trying to remember when things started turning so shit</strong> when he wrote this post</span>

Viewing 2 replies - 1 through 2 (of 2 total)
  • echo "<span>".get_the_author()." was <strong>".get_post_meta($post->ID, "Mood", true)."</strong> when he wrote this post</span>";

    Note I changed the line above to use get_the_author(), which only returns the author name value. the_author() already echoes it, hence the doubling you are seeing.

    Moderator note: Moved thread to more appropriate forum.

    Cheers Kafka, that did the job. I thought it was something like that but I couldn’t find anything in the help section.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘the_author displays twice’ is closed to new replies.