Pssst. Want us to customize your theme for half the price?
If you’re up for it, adding a post signature using your functions file is going to be the cleanest, fastest way to insert the code. It can easily be the most confusing, daunting, and destructive, too! I like to do everything in my functions file because I know that it can’t be effected by an outdated plugin and also because all my code is in a central location, rather than having to load more than is necessary. Just read along to learn how to work in your own functions file safely.
Why choose to not use a plugin?
- Level of difficulty: challenging
- Pros: cut down on plugin load time, don’t worry about plugins becoming outdated, greater control over the output (and location) of your signature
- Cons: if you don’t know your FTP (File Transfer Protocol) information, breaking your functions file (and thus site) can be a real headache (so make sure you can login to that before you get started!)
How to tell if you’re using HTML5
If you’re using an HTML5 enabled Genesis child theme, you’ll have the following line in your functions file.
add_theme_support( 'html5' );
Then, this code you can just copy and paste into the bottom of your functions file:
//* Add a post signature add_filter( 'genesis_entry_content', 'post_signature' ); function post_signature() { if ( is_single() ) { printf ('<div class="post-signature' . get_the_author_meta('user_login') . '"> [INSERT SIGNATURE TEXT] </div>'); } }
What to do if you’re not
If you don’t have an HTML5 enabled Genesis child theme, your code looks slightly different.
//* Add a post signature add_filter( 'genesis_after_post_content', 'post_signature' ); function post_signature() { if ( is_single() ) { printf ('<div class="post-signature' . get_the_author_meta('user_login') . '"> [INSERT SIGNATURE TEXT] </div>'); } }
Styling
You’ll notice that our styles are still pretty much the same as both of our previous options: Add Signature (Reloaded) and Genesis Simple Hooks.
.post-signature { font: italic 14px Georgia; color: #CC0033; }
I usually don’t insert any text, and instead give the div a background image from my stylesheet.
.post-signature { background: #fff no-repeat right center url('[IMG_URL]'); height: IMG_HEIGHT; }
And again, we can use the author’s username to insert a specific style or image:
.laurengray { background: #fff no-repeat right center url('[IMG_URL]'); height: IMG_HEIGHT; }
Essentially, there you have it! But we have to beware that some plugins may displace your signature to below their content (rather than directly below your post). So next we’ll discuss how we can use our functions to rearrange the order in which our content appears – which actually isn’t as difficult as it sounds!
pssst.. Check out our sister brands!
Leave a Reply