Jump to content
Sign in to follow this  
tuanma

Hooks Help: Adding Social Button Before Content

Recommended Posts

tuanma    0
tuanma

Hello, Wanted to see if there was anyone who could assist me in getting my hook to work the way I want. I have a hook that adds a social button before content, however, I only want it to appear in posts. Currently, it's appearing in posts and pages. I have the following which needs an "if"....

add_action('pagelines_loop_before_post_content', 'add_social_btn');
	function add_social_btn(){
	?>
	
	<?php }
	
	[/code]

Thanks in advance.

Share this post


Link to post
Share on other sites
Andrew    201
Andrew
sure, just wrap a [code] if(is_single()){ (your code) } [/code] around it :)

Share this post


Link to post
Share on other sites
tuanma    0
tuanma
Tried the following and site crashed. I think I have some of the coding wrong....a newbie here. add_action('pagelines_loop_before_post_content', 'add_social_btn'); function add_social_btn(){ ?> if(is_single()){ ( ) }

Share this post


Link to post
Share on other sites
Jenny    33
Jenny
You're closing out your php before the if(is_single()) call, which is not good. This code should work for you (although we cannot verify your iframe code to know if it's right): [code]add_action( 'pagelines_loop_before_post_content', 'add_social_btn' ); function add_social_btn(){ if( is_single() ) { echo ''; } }[/code]

Jenny :: Web designer at Simple Mama (follow me at @simplemamacom)

Check out Share Me, a social sharing add-on for DMS that is super simple to set up.

Share this post


Link to post
Share on other sites
tuanma    0
tuanma
Thanks for your help. Worked like a charm.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×