Pages?
-
Mod
You can add them in using an action hook.
If you install the plug in then you get a settings page for it under settings in the WP dashboard. And it lets you adjust the html tags but not wrap them in divs that I can see.
This is not crucial so if you are busy please don’t feel obliged 🙂 You have been so helpful to me!
I’m playing with it now. This is a tricky little sucker 😉
I’ll get back to you shortly.
Ok, instead of adding the plugin through WordPress, let’s just get the code for “website” instead. This will give you the html code and the script code. Then we can just insert it (using Ken’s suggestion above) with an action hook.
So, on the sharethis site… instead of the default tab (toward the top) click “website” instead.
Oh, good idea! Ok…so here is the code generated that way on the website tab…
<span class=’st_twitter_hcount’ displayText=’Tweet’></span><span class=’st_facebook_hcount’ displayText=’Facebook’></span><span class=’st_fblike_hcount’ ></span><span class=’st_plusone_hcount’ ></span>
<script type=”text/javascript”>var switchTo5x=true;</script><script type=”text/javascript” src=”http://w.sharethis.com/button/buttons.js”></script><script type=”text/javascript”>stLight.options({publisher:’a3fd7349-1e52-4dff-8567-b74f16e9be5c’});</script>
now what? 🙂
Okay, where are you wanting to display this code? (Posts? Pages?)
Okay,
I’m not quite sure how to keep it off the home page slider. I’d also like to know. Ken or Syahir, perhaps you can help 🙂
But, to get started…
Wrap the first and last span tags, from the first part, in a div. ie..
<div id="sharethis"><span class='st_twitter_hcount' displayText='Tweet'></span><span class='st_facebook_hcount' displayText='Facebook'></span><span class='st_fblike_hcount' ></span><span class='st_plusone_hcount' ></span></div>Now, create a function in your child functions.php
You can copy and paste the function below into your code (I made the adjustments for you personally. Just make sure you keep them consistent throughout. You should be able to copy and paste everything I posted here):
function laura_sharethis (){
?>
<div id="sharethis"><span class='st_twitter_hcount' displayText='Tweet'></span><span class='st_facebook_hcount' displayText='Facebook'></span><span class='st_fblike_hcount' ></span><span class='st_plusone_hcount' ></span></div>
<?php
}
add_action( 'graphene_after_post_content', 'laura_sharethis' );1. We can name the function whatever we like, It needs to be the same as in the
add_actioncode, which I’ll explain in a second.2. Note the div id, which we also custom named. This will match the css element we create in our child style.css
3. The
do_actionandadd_actionwork together as a “hook”. They are scattered all throughout the code. If you look in your graphene loop.php file, you will notice a little over halfway down, there is a<?php do_action('graphene_after_post_content'); ?>code. So, we want to tell it every time it seesdo_action ( 'graphene_after_post_content' )to automatically insert ourdo_action ( 'larua_sharethis' )right afterwards. We “hook” it to the function.We are going to “hook” our function to this one. So, this is going to be the first part of our custom function
add_action(resulting in thisadd_action( 'graphene_after_post_content', 'laura_sharethis' );.Lastly, create your css element in your child stlye.css file. Remember, this needs to match the div id we created earlier. So
#sharethis {is what you want to use.Just add any properties you need in the css to position it where you like.
Hope this all makes sense 🙂
- You must be logged in to reply to this topic.
