the_author displays twice
-
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'); ?> <?php $mymood=get_post_meta($post->ID, "Mood", $single=true); if(strlen($mymood)>0) { 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 postThe html it generates is:
Posted in <a href="https://www.wonkosworld.co.uk/wordpress/category/general/" title="View all posts in General" rel="category tag">General</a> by: wonkotsane <a href="https://www.wonkosworld.co.uk/wordpress/wp-admin/post.php?action=edit&post=848">Edit</a> <br/> <a href="https://www.wonkosworld.co.uk/wordpress/2007/10/26/i-would-say-this-takes-the-biscuit-but/#comments" 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>
- The topic ‘the_author displays twice’ is closed to new replies.