WordPress.org

Ready to get started?Download WordPress

Forums

Multiple Author Signatures (1 post)

  1. breezlin
    Member
    Posted 4 months ago #

    I run a multi-author site and I wanted each author to have their own signature image display under each post.

    When I enter this code in the functions.php it works perfectly, but obviously it puts the one image under ALL the posts...but it works.

    add_filter('the_content','add_signature');
    function add_signature($text) {
    global $post;
    if($post->post_type == 'post')
    $text .= '<div class="signature">
    <div style="text-align:center;">
    <img src="http://booksbeyondtheend.com/katsig.png" alt="kat" />
    </div>';
    return $text;
    }

    So when I go with this code to separate it out for the multiple authors, I get a 500 error and the site is stating that the post part of the 4th line is causing the error. I don't understand why though.

    add_filter('the_content','add_signature’);
    function add_signature($text) {
    global $post;
    if($post->post_type == 'post') {
              if ( get_the_author() == 'Kat MacKenzie' ) {
                   $text .= '<div class="signature">
                   <img src="http://booksbeyondtheend.com/katsig.png" alt="kat" />
                   </div>';
              } else if ( get_the_author() == 'Alex Black' ) {
                   $text .= '<div class="signature">
                   <img src="http://booksbeyondtheend.com/alexsig.png" alt="alex" />
                   </div>';
              } else if ( get_the_author() == 'Adeleas Wellington' ) {
                   $text .= '<div class="signature">
                   <img src="http://booksbeyondtheend.com/adeleassig.png" alt="adeleas" />
                   </div>’;
              }
    
         return $text;
    }

    I don't know how to write code so speak to someone with limited understanding of all that. Thanks!!
    (also, I am using a child theme, twenty twelve theme fyi)

Reply

You must log in to post.

About this Topic