Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
function socialbutton($content) {
    if(is_single()) {
            $content.= '
     <div class="author_info">
    <h4>This post was written by <?php the_author_posts_link(); ?></h4>
    <span class="author_photo"><?php echo get_avatar( get_the_author_id() , 96 ); ?></span>
    <p><?php the_author(); ?> &ndash; who has written <?php the_author_posts(); ?> posts on <a href="<?php bloginfo('home'); ?>"><?php bloginfo('name'); ?></a>.</p>
    <p><?php the_author_description(); ?></p>
    <p class="author_email"><a href="mailto:<?php the_author_email(); ?>" title="Send an Email to the Author of this Post">Contact the author</a></p>
    </div>'; 
    }
    return $content;
    }add_filter ('the_content', 'socialbutton');

When I add the code above to function.php, it shows

Parse error: syntax error, unexpected T_STRING in XXXXXX on line 10

How to solve this problem?

share|improve this question
2  
That is a giant mess, maybe php.net/manual/en/getting-started.php –  Wyck Jul 18 '11 at 3:34
    
Also, a generic PHP error really isn't a WordPress question or issue. –  Chip Bennett Jul 18 '11 at 12:02
add comment

1 Answer

up vote 1 down vote accepted

You need to escape your single quotes on the author line, or use double quotes instead. For example, change to:

<a href="<?php bloginfo(\'home\'); ?>"><?php bloginfo(\'name\'); ?>

or

<a href="<?php bloginfo("home"); ?>"><?php bloginfo("name"); ?>

This is because you started your output string with single quotes, and so it is ending the HTML content to insert too soon.

share|improve this answer
    
@Chang you're also going to run into issues with using the contextually inappropriate WordPress functions. To return rather than print data, you need to use e.g. get_the_author() instead of the_author(), and get_bloginfo() instead of bloginfo(). (Note: not exhaustive; I recommend checking every single WP template tag to verify you're using the correct one.) –  Chip Bennett Jul 18 '11 at 12:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.