Title: Function only show on posts
Last modified: July 13, 2020

---

# Function only show on posts

 *  Resolved [sjoerd89](https://wordpress.org/support/users/sjoerd89/)
 * (@sjoerd89)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/function-only-show-on-posts/)
 * Hi all,
 * not sure if this is the right place on the forum to ask this but let’s try.
    
   I have a function that shows a linkedin share button on my website. It looks 
   like this:
 *     ```
       function wpb_linkedin_share_after($content) { 
       $sharecode .= '<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US</script>
       <script type="IN/Share" data-counter="top"></script>'; 
       $newcontent = $content . $sharecode; 
       return $newcontent; 
       } 
       add_filter('the_content', 'wpb_linkedin_share_after');
       ```
   
 * Now i would like this only to show up on “post” types. I read about the part 
   where you have to specify what kind of type of page it is but can’t figure it
   out.
 * Thanks for your help!
 * Sjoerd

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [mrtom414](https://wordpress.org/support/users/mrtom414/)
 * (@mrtom414)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/function-only-show-on-posts/#post-13114959)
 * maybe you should try doing a conditional statement.
 *     ```
       if(get_post_type() == 'post') {
   
       sharecode .= '<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US</script>
       <script type="IN/Share" data-counter="top"></script>'; 
       $newcontent = $content . $sharecode; 
       return $newcontent;
       } else{
       return $content;
       }
       ```
   
 * You would have to add the post types you want to check for. I’m not sure if it
   what you are looking for.
 *  Thread Starter [sjoerd89](https://wordpress.org/support/users/sjoerd89/)
 * (@sjoerd89)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/function-only-show-on-posts/#post-13114974)
 * > You would have to add the post types you want to check for. I’m not sure if
   > it what you are looking for.
 * I would like to have it on all post pages. But in your code i do not see where
   i have to specify this.
 *  [mrtom414](https://wordpress.org/support/users/mrtom414/)
 * (@mrtom414)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/function-only-show-on-posts/#post-13115153)
 * your original code should put it on each post. I thought you wanted it only on
   specific post types. Are you wanting it on every post or only once per page. 
   I’m a little confused when you say post page.
 *  Thread Starter [sjoerd89](https://wordpress.org/support/users/sjoerd89/)
 * (@sjoerd89)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/function-only-show-on-posts/#post-13115178)
 * I am sorry if i am not completely clear with my question.
    In wordpress i have
   two places i make pages for my website: 1: Pages 2: Posts
 * With my original code, the function showed on every page of my website. But i
   would like it to only show on the post type pages. Inside the posts, i have two
   categories if that is needed but i want the function to show on both categories.
 *  [mrtom414](https://wordpress.org/support/users/mrtom414/)
 * (@mrtom414)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/function-only-show-on-posts/#post-13117250)
 * You just want it to post on the homepage where your blog post are being displayed.
 *     ```
       if(is_home() ){
   
       sharecode .= '<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US</script>
       <script type="IN/Share" data-counter="top"></script>'; 
       $newcontent = $content . $sharecode; 
       return $newcontent;
       } else{
       return $content;
       }
       ```
   
 *  Thread Starter [sjoerd89](https://wordpress.org/support/users/sjoerd89/)
 * (@sjoerd89)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/function-only-show-on-posts/#post-13119697)
 * Thanks for your time, i got it too work!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Function only show on posts’ is closed to new replies.

## Tags

 * [functions](https://wordpress.org/support/topic-tag/functions/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 2 participants
 * Last reply from: [sjoerd89](https://wordpress.org/support/users/sjoerd89/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/function-only-show-on-posts/#post-13119697)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
