• 0
Sign in to follow this  
Followers 0

Hooks Help: Adding Social Button Before Content

Question

Posted · Report post

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

4 answers to this question

  • 0

Posted · Report post

sure, just wrap a [code] if(is_single()){ (your code) } [/code] around it :)

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

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
  • 0

Posted · Report post

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]

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

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  
Followers 0