• Shan

    (@shan-last-shreds-of-sanity)


    I found a hack that sort of worked:

    I added this to my functions.php file:

    add_filter('the_content','add_signature');
    function add_signature($text) {
     global $post;
     if($post->post_type == 'post') $text .= '<div class="signature"> <img src="http:/yoursite.com/wp-content/themes/yourtheme/images/signature.png" alt="signature" /> </div>';
     return $text;
    }

    But instead of my signature being directly under the content, it was below both my linkwithin & sociable plugin stuff and above the tags/category meta info. How do I code it so that it goes directly at the end of my posts and above all the other stuff?

Viewing 15 replies - 1 through 15 (of 40 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    It’s a matter of when the filter gets queued and applied. Try modifying the add_filter() like so:

    add_filter('the_content','add_signature', 1 );

    I usually make my filters run later with ,11 so this may not work… If it does work it’ll get applied earlier than the default priority.

    Thread Starter Shan

    (@shan-last-shreds-of-sanity)

    OK, that worked. Thank you so much! But I can’t get it centered. I added this to the css but nothing happened:

    div.signature img {
    padding: 5px;
    float: center;
    }

    Also, now my related posts are above my social icons. I have no clue how that happened. Any idea how to fix it?

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    *Jan senses Esmi saying “Use the Firebug, Luke.”*

    I always struggle with the CSS portion but this seems to do it.

    div.signature {
            text-align: center;
            padding: 5px;
    }

    I don’t really know why, but it works. ??

    Also, you want to save yourself grief and not hard code URLs like that. Try this modification to the function.

    add_filter( 'the_content' , 'add_signature' , 1 );
    function add_signature($text) {
       global $post;
       if($post->post_type == 'post') $text .= '<div class="signature"> <img src="' . get_stylesheet_directory_uri() . '/images/signature.jpg" alt="signature" /> </div>';
       return $text;
    }

    By using get_stylesheet_directory_uri() you can have the function figure out and produce the URI for the theme directory.

    Also, now my related posts are above my social icons. I have no clue how that happened. Any idea how to fix it?

    That’s an odd one. Can you share the link?

    Edit: Forgot the padding.

    Thread Starter Shan

    (@shan-last-shreds-of-sanity)

    Thanks I’ll try the last bit and see what happens. ??

    And I did use Firebug — can’t live without it — but none of the normal rules worked. I thought of text-align, but since it’s an image, I didn’t use it. LOL

    Here is a post: https://lastshredsofsanity.com/top-10-last-minute-valentines-gifts-not-to-buy-for-your-woman-unless-you-want-to-get-kicked-in-the-nuts/

    It’s weird. I’m using LinkWithin for related posts and Sociable 2 for social icons (which just updated 15 minutes ago and is all kinds of FUBARED on settings)

    Thread Starter Shan

    (@shan-last-shreds-of-sanity)

    Don’t I need to add the image URL for the CSS now?

    Like this:

    div.signature {
            background: url('http:/yoursite.com/wp-content/themes/yourtheme/images/signature.png');
            text-align: center;
    }

    Never mind, that last bit did not work. ??

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    It’s weird. I’m using LinkWithin for related posts and Sociable 2 for social icons (which just updated 15 minutes ago and is all kinds of FUBARED on settings)

    Disable your add_filter() just to rule out any changes that you made. If it’s still doing odd things, then it’s the plugin.

    If it goes back to normal… it’s something you’ve done. ??

    Don’t I need to add the image URL for the CSS now?

    If you want to use the image as a CSS background, then yes. But your function adds a img src= tag, so the png file is already there. Adding the additional background image isn’t necessary.

    Thread Starter Shan

    (@shan-last-shreds-of-sanity)

    Well it’s either a a quote issue or my theme but the image won’t show with the changed php you gave me.

    Parse error: syntax error, unexpected T_STRING in /home/XXX/public_html/wp-content/themes/shan-wp-ellie_basic/functions.php on line 2194

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Sorry, it’s worse than that, there is a typo somewhere in that functions.php file!

    Can you undo the changes? Right now your WordPress blog is tossing errors.

    Also I apologize: I should always start with “Please make a backup copy before you edit that file”.

    Thread Starter Shan

    (@shan-last-shreds-of-sanity)

    Uggh. Back to original functions.php file now.

    Where is the typo? I suck at php code, if you haven’t already guessed. LOL

    EDIT: still getting parse error even with original functions file added back. OY.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    It’s still tossing errors for me. Do you have a backup?

    Or if you don’t have a backup, can you use an original copy from where you got that theme?

    Thread Starter Shan

    (@shan-last-shreds-of-sanity)

    I did add the original php code back to the functions file both via the theme editor and FTP. I don’t get it. It’s like it won’t take.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Hrm.

    Try this: Via your FTP client, rename the directory shan-wp-ellie_basic to shan-wp-ellie_basic-old.

    Now in that renamed dictory, rename shan-wp-ellie_basic-old/style.css to shan-wp-ellie_basic-old/style.css-old.

    What I want is for that messed up theme to stop being used. By renaming the directory and the style.css both, then WordPress should stop seeing that as a theme.

    Once you’ve done that, upload a backup copy of the entire shan-wp-ellie_basic folder there. This way you’ll have two directories, one -old and the backup copy.

    See if that works.

    Thread Starter Shan

    (@shan-last-shreds-of-sanity)

    This is the error I’m getting:

    Parse error: syntax error, unexpected '}' in /home/XXX/public_html/wp-content/themes/shan-wp-ellie_basic/functions.php on line 1

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Yep, that’s the same error I’m seeing too.

    Thread Starter Shan

    (@shan-last-shreds-of-sanity)

    Ok, I named the original -old and uploaded a clean theme. Is it Ok to add the style sheet?

Viewing 15 replies - 1 through 15 (of 40 total)
  • The topic ‘How To Add Signature To Posts Without A Plugin?’ is closed to new replies.