Pssst. Want us to customize your theme for half the price?
Now that we know about hook priorities and how we can use them to set the order of importance for our page elements, let’s apply that knowledge to our signature, and making sure that we can insert our signature after our content but before our share buttons and related content. We’ll be moving post signature above related content and share buttons.
I’m going to show you how to work with the Shareaholic plugin, but if you’re using the nRelate plugin, head over to 1dogwoof.com for how to set the display priority. Here we go!
Getting the shortcode
If you’ve already had Shareholic installed, you’ve got it all set up and are probably having it inserted automatically. In order to assign where this plugin displays, we need to turn that setting off, and use our functions to insert the shortcode manually. So let’s grab our shortcode for later.
Go to your WordPress Dashboard > Shareaholic and click on the ‘Customize’ button. At the bottom, there’s a shortcode. Copy that! That ID is specific to your content, so it’s what you need to have – unless you want to be linking to my content, which I’m OK with!
Putting the code in functions.php
We already have our signature in our functions file, but we want to assign a priority to it.
//* Add a post signature add_filter( 'genesis_entry_content', 'post_signature', 10 ); function post_signature() { if ( is_single() ) { printf ('<div class="post-signature' . get_the_author_meta('user_login') . '"> </div>'); } }
Great, now let’s put that shortcode in, making sure we give it a higher priority!
//* POSTS Move related content below signature add_filter( 'genesis_entry_content', 'shareaholic_related', 12 ); function shareaholic_related() { if ( is_single() ) { echo do_shortcode ('[shareaholic app="recommendations" id="4802086"]'); } }
Just make sure you’re replacing that ID number with your own!
Think you can duplicate the code above but change it just a bit to include your share buttons? Try! A solution is below:
//* POSTS Move related content below signature add_filter( 'genesis_entry_content', 'shareaholic_buttons', 11 ); function shareaholic_buttons() { if ( is_single() ) { echo do_shortcode ('[shareaholic app="share_buttons" id="4802082"]'); } }
How’d you do? I know, I know, I haven’t taught you all the secrets yet. Well, the main takeaway is that you just need to change the priority and then the shortcode to reflect the share buttons. But if you tried it out and got an error, it’s probably because you didn’t change the function name. Those can only be used once. Anyway, good job! 🙂
pssst.. Check out our sister brands!
Leave a Reply