LinkedIn Logo

Showing more of your LinkedIn profile with WP-LinkedIn

Since I released the WP-LinkedIn plugin for WordPress I got this same request coming regularly about how to add this or that profile information to the output of the plugin. Here is an example that will show you how to add the headline for the recommender.

So let’s say you want that, in the list of recommendations, the current position of the recommender shows up beside their name.

First thing to do when you want to show more profile information is to verify that the information is actually provided by the LinkedIn API. Let’s head up to the LinkedIn API documentation and check if the latest position of the recommender is available.

It’s not really indicated but the “recommender” field in the recommendations is an instance of a “Basic Profile” object for that person (or at least it has a number of the same fields that make a basic profile). If you look at the basic profile fields you will see that there is a collection of “positions” and that positions objects have a “is-current” flag that will tell you wether it’s current or not.

In theory we could use that to determine the curent positions of the recommender but there could be more than one, which would be a problem in our case. Instead, you will notice that the basic profile object also has a “headline” field which is the field people use to actually describe their current roles and positions. We are going to use that field instead of computing the current position.

Once we know what field to use we need to tell the plugin that field needs to be fetched. Go to the LinkedIn options page in the WordPress admin panel and add the “headline” field to the list of fields. If you had the defaults in the LinkedIn option page it should now look like that:

summary, specialties, languages, skills, educations, positions, recommendations-received:(recommendation-text,recommender:(first-name,last-name,public-profile-url,headline))

Now we need to display that information. To do that you need to create custom LinkedIn templates: create a “linkedin” folder in your theme and copy the “recommendations.php” and “profile.php” templates from the plugin folder. Then you will need to change those templates to print the headline. For example in “profile.php” add the following line at line 90 of the file:

if (isset($v->recommender->headline)) echo ' - ' . $v->recommender->headline;

Et voilà! If you have any question or remark, feel free to post a comment :)

Image Credits: Jerry Luk

Independent Software Professional
I am a freelance software developer with more than 20 years of professional experience and a broad IT culture. I am passionate about my job, a recognized mentor and I help startups, non-profit organizations, governments agencies and multinational companies to build and operate web solutions ranging from simple blogs to intranet applications and highly scalable web applications.

I am location independent, work exclusively remotely and rarely meet my clients in person. I share my experience, as a developer and as a traveler on my blog at vedovini.net. Do not hesitate in contacting me if you are interested in my services or my way of life.

55 thoughts on “Showing more of your LinkedIn profile with WP-LinkedIn

  1. Andrea Reed

    This is great info! I added the info to line 90 of profile.php. I am not sure what modifications to make to recommendations.php. Could you advise?

    Reply
    1. Claude Vedovini Post author

      Hello Andrea,
      To do the same thing in `recommendations.php` make sure that lines 10 through 13 look like that:

      <div class="recommender"><a href="<?php echo $recommendation- rel="nofollow">recommender->publicProfileUrl; ?>"
          target="_blank"><?php echo $recommendation->recommender->firstName; ?> <?php echo $recommendation->recommender->lastName; ?></a>
          <?php if (isset($recommendation->recommender->headline)) echo ' - ' . $recommendation->recommender->headline; ?>
      </div>
      Reply
  2. Killian Clifford

    Hi thanks for this – I have made all of the above changes but in recommendations.php nothing is being pulled back for:
    recommender->headline; ?>

    i.e. it is not being defined or recognised? Any ideas – I have added ‘headline’ as a field under the linked in option page

    thanks

    Reply
    1. Claude Vedovini Post author

      Hi, actually there’s a small issue here.
      You can customize the template but not the list of fields for the recommendation slider. It should come with the next release.

      Reply
  3. tyler

    Hi. I love the idea of your plugin, but I cannot get it to retrieve the profile. It keeps saying “profile could not be received”. And for the recommendations it says I have none when I do actually have some on my linkedin profile. I have regenerated the api and cleared caches

    Reply
  4. Pingback: How to Showcase your LinkedIn Profile and Recommendations on Wordpress | Adrian Chu

  5. Piero Zilio

    Hi Claude, and thanks for this great plug-in. I am having issues using picture-url LinkedIn field.

    I have added the picture-url field to the list of fields in the LinkedIn options page in the WordPress admin panel.

    I have created a linkedin folder in my active template folder.

    I have added this line in my profile.php and added the file in the linkedin folder within my active template folder:

    if (isset($v->recommender->picture-url)) echo $v->recommender->picture-url;

    Error message says:

    Parse error: syntax error, unexpected '-', expecting ',' or ')'

    Perhaps due to the characters used in the linkedin field “picture-url” it is not possible to use it?

    Reply
    1. Claude Vedovini Post author

      picture-url is not a valid PHP identifier, it’s more likely that the name of the attribute would be pictureUrl if it was actually returned. The LinkedIn API seems to accept that you ask for the recommender’s picture but is not returning it.

      Reply
  6. Marcel

    Hello Claude,

    I am building a personal website with the Pytheas theme.

    I ust installed your LinkedIn plugin for WordPress’to present my LinkedIn profile on my profile page. After activating your plugin, my slider on the homepage stops working (I deactivated all plugins and it is really the LinkedIn plugin causing this).

    This is the theme
    http://wpexplorer-demos.com/pytheas/
    (I cann’t show you my website, because is still on localhost).

    Do you know what might be the problem?

    The picture slider you see on the homepage stops working/freezes after installing this plugin. I hope you can help, because I really like the plugin (and changing the theme isn’t an option).

    Greetz
    Marcel

    Reply
    1. Claude Vedovini Post author

      Hi Marcel,

      It appears that there’s often conflict between the slider that is used in the standard templates of the plugin and other sliders (in themes or otherwise). In that case I recommend you customize the templates to use the slider from your theme (in your case flexslider) instead of jQuery TOOLS’ scrollable.

      C.

      Reply
      1. Marcel

        OK thanx for your swift reply.

        Uhm… Sounds as a difficult PHP job. I’m known with CSS, but not so much with PHP or other more serious coding.

        I think I will swap then to an another LinkedIn plugin (which doesn’t affect my theme slider), sorry.

        Gr
        Marcel

        Reply
        1. Claude Vedovini Post author

          It’s actually explained in the blog post up there.

          Create a “linkedin” folder in your theme and copy the “recommendations.php” template from the plugin folder. Then change that template.

          Reply
          1. Marcel

            I’m really stuck here… I copied the recommendations.php to a linkedin folder and then changed this recommendation.php by replacing the javascript for flexslider javascript. But then still my slider of the homepage is broken…

          2. Claude Vedovini Post author

            Try adding the following PHP at the beginning of your template:

            wp_dequeue_script('jquery.tools');
            wp_dequeue_script('jquery-dimension-etc');
          3. Marcel

            Or should it in the functions.php and look like this?
            <?php
            function jquery_remove_scripts(){
            wp_dequeue_script( 'jquery.tools' );
            wp_dequeue_script( 'jquery-dimension-etc' );
            }
            add_action( 'init', 'jquery_remove_scripts', 100 );
            <?

  7. Marcel

    Place within the beginning on the recommendations.php of the plugin? Or at the beginning of the template of my theme?

    Reply
    1. Claude Vedovini Post author

      I was talking about the beginning of the recommendations.php template in your theme. But the version where you put it in functions.php is better, just hook up your remove function to the “wp_enqueue_scripts” hook instead of “init”.

      Reply
      1. Marcel

        yup, I made a typo there, thanks!

        I ended up in putted this code in the functions.php of my template:

        function jquery_remove_scripts(){
        wp_dequeue_script( ‘jquery.tools’ );
        wp_dequeue_script( ‘jquery-dimension-etc’ );
        }
        add_action( ‘wp_enqueue_scripts’, ‘jquery_remove_scripts’, 100 );

        And finally all the things are working fine with the slider! Many thanks!

        Reply
  8. Steve

    Hi Claude, nice plugin. I’m trying to add just the activity feed (what we have been commenting on in LinkedIn) to a webpage. Any ideas on how to achieve that?

    Reply
    1. Claude Vedovini Post author

      Hi James,
      Unfortunately there’s currently nothing to help you with that in my plugin.
      Might come in the future tho, but i cannot give you a date.
      C.

      Reply
    1. Claude Vedovini Post author

      Good idea Mike, I might add that in a next version. In the mean time you can customize the recommendations.php template and add the following line near the top of the file:

      shuffle($recommendations);
      Reply
        1. Mike

          Claude, I’m notice that every few weeks or so, I have to go in and change the margin/random display settings for the widget. I’m assuming the widget is on an auto update configuration for security/enhancement reasons… But I have to keep going back in and altering the settings like margin-left -46px any ideas on how to keep my settings in tact?

          Reply
          1. Claude Vedovini Post author

            Hi Mike,

            If you make your changes directly inside the plugin files they will get overwritten with each update of the plugin.

            To avoid that I recommend you make your changes into your theme CSS, use a plugin like Jetpack to add the custom CSS or copy the customized template into your theme like indicated in that post.

            Regards,
            C.

          2. Mike Cortez

            Claude,

            I seem to be having trouble making the recommendations possible “jetpack” to alter the css into the theme. Do you have any other suggestions?

          3. Claude Vedovini Post author

            Like I said previously you have 3 solutions:

            • make your changes into your theme CSS,
            • use a plugin like Jetpack to add the custom CSS (you can find several others) or
            • copy the customized template into your theme like indicated in that post.

            HTH
            C.

    1. Claude Vedovini Post author

      Hi Stewart,
      If this is your own updates that you are trying to display then there is the [li_updates] shortcode that you can use. You will need to customize the template but there will be differences. What that page is showing is a list of blog posts published by LinkedIn (they all have a title, an image and an excerpt). Your updates are a disparate collection of shares, status updates and network informations (like the fact you just changed your profile info) so the result cannot look just like that.
      C.

      Reply
  9. Pingback: How to customize the recommendations scroller in WP-LinkedIn | vedovini.net

  10. Debbie Dean

    Hi,

    Is there a way to configure the Network Updates Widget so it displays text from updates/stream rather than links back to the profile?

    Thanks,
    Debbie

    Reply
    1. Claude Vedovini Post author

      Hi Debbie,
      That’s already what it’s supposed to do but I reckon there’s a bug in the function that extract links from the updates, I will issue a bug fix soon :)
      Thanks for the reporting,
      C.

      Reply
  11. Debbie Dean

    Hi,

    That’s more like what I want to show, but would it be possible to remove the profile name from the beginning of each line?

    Thanks,
    Debbie

    Reply
    1. Claude Vedovini Post author

      you need to customize the “network-updates.php” template, this post explains how to do that with the “profile.php” template but it is the same mechanism.

      Reply
  12. stinti424

    Hi Claude, such a great plugin!
    Actually I’m not quite sure on how I can change the length of the summary in the card widget; I see there’s the summary_length attribute, but how can I use it? (Sorry for the probably goofy question, but my coding skills are almost inexistent ;) )
    Thanks a lot!

    Reply
    1. Claude Vedovini Post author

      Hi,

      It depends how you insert the card. If you use the widget then it’s in the widget admin interface, if you use the shortcode you must add the ‘summary_length’ attribute to the shortcode, if you use the automatic insertion then the summary length is fixed at 2000 characters.

      Finally, it’s not documented but you can use the template tag: wp_linkedin_card(array('summary_length' => 2000));

      HTH
      C.

      Reply
  13. ad

    Hi Claude: I had two questions:
    1) The recommendations are being chopped toward the end of each line…How do I ensure each line is not chopped?
    2) I am being unable to make headline work? Can you please lay down the process one more time to add headline? Thank you for the great work!

    Reply
    1. Claude Vedovini Post author

      Hello,

      You have to specify the exact width in pixel you want for the slider, however in that case it won’t work for responsive design. If you want the slider to be responsive you have two options,
      1. you specify the width as “auto”, however it may not work in all configurations or
      2. you specify the with as “css” and then you set the width yourself in your css file

      if you want to change the javascript component you will need to customise the template for the recommendations scroller. Check that other article, as there’s a small difference with the profile: http://vedovini.net/2014/01/how-to-customize-the-recommendations-scroller-in-wp-linkedin/

      Reply
  14. ad

    Also, I just tested the recommendation slider in ihone 5s and the slider does not work, but text. How can I change the slider you are using to meta slider? What code (where) do I need add/remove to make it a responsive slider?

    Reply

Leave a Reply