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 your wp-content folder and copy the recommendations.php and profile.php templates from the plugin folder (copying the customized templates in the theme folder still works but, as of version 1.19, this is the preferred method). Then you will need to change those templates to print the headline. For example in “profile.php” add the following code 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

71 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
  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
  15. Anthony Michaels

    Hey man, greetings, it’s been a while. Question… I have this simultaneous strike-through and underline being displayed left/right(if I css w direction rl)(trying to trim/ellipsis – bad idea) of the ‘recommender’ in the scrolling area. I’m not sure what this thing is, but I’m betting it’s a call from echo… just haven’t determined where… text-decoration: none does nothing as it does not appear to be text rather solid object like a picture.

    Reply
    1. Claude Vedovini Post author

      the “rtl” CSS changes the side the :before pseudo element will be but it’s coming from this :before CSS directive which contains “text-decoration: underline;” which is not part of the original CSS coming with the plugin, did you change it? However, the dash before the name is part of the original CSS it just happens to be underline and put behind because of CSS modifications on “.linkedin blockquote .recommender” and “.linkedin blockquote .recommender:before”

      Reply
      1. Anthony Michaels

        i managed to determine that since I couldn’t find any .css or .php file that could account for this mistake yet when I used developer tools to source code it the error it showed as a duplicate, I ran back through until I found an area on the site that would self generate. Sadly, WP with Avada has 3-4 methods for accomplishing this change… and my carelessness overlooked one of them, the glaring “theme options/custom css” as opposed to WP/Appearance/Edit CSS, WP/Plugins/Editor, and conventional CPanel File Manager. So needless to say, I got it worked out… Thanks for responding…

        I do have one more question however, can I make a character exception script of sorts? e.g., I can tell the code to display max characters for recommendations, but it would be nice if I could exclude comments from displaying which have less than 40 characters. Is this possible? Thanks.

        Reply
        1. Claude Vedovini Post author

          You can always customize the profile template or the recommendation template to do filter out shorter recommendations. Basically the same process than described on this post but with different templates.

          Reply
          1. Anthony Michaels

            Only thing I can see remotely close to that is and it seems that wouldn’t do anything as that php function would be altering a php element where I believe the linkedin slider is actually a .js container… Anyway, I’ve been fishing around to no avail on how to not show recommendations with less than 60 characters. Any help is appreciated. Thanks again.

            “$(function(){
            $(‘#slider’).slider({
            min: 50,
            max: 2500
            });
            }); “

          2. Claude Vedovini Post author

            In the recommendations.php template (and profile-recommendations.php) there’s a loop to print the recommendations, you just need to insert a if statement to output only longer recommendations. Just make sure you don’t modify the files in the plugin but put your customized templates in the wp-content/linkedin folder as indicated.

          3. Anthony Michaels

            Yea, I’ve tried every If statement on ‘$recommendation’…
            if (count($recommendation) > 160){
            if ($recommendation > 160) {
            different arguments to include strlen and several different functions in several different areas… it will not exclude recommendations of certain character minimums, I think I’m going to give up and just copy + paste my recommendations in to word to spell check them and use my themes review “slider” function 8 hours later. Thanks anyway.

          4. Claude Vedovini Post author

            well, the text of the recommendation is in $recommendation->recommendationText or something similar, $recommendation is an object

          5. Anthony Michaels

            I had a friend who is a programmer put together some nifty stuff… nothing I would have been able to do by myself… seems more complex than simple “if statement”, why does the profile-recommendations.php need to be amended as well? Also wp-content/plugins can be overridden which is why I suspect you state to have a linkedIn folder in ../wp-content

            Am I to delete the wp-content/plugins/wp-linkedin afterwards?

          6. Claude Vedovini Post author

            both templates display the recommendations, one as part of the profile and the other is the slider. you might want to have different ways to show them.

            do not delete the plugin, the wp-content/linkedin folder should contain only the customized templates not the full plugin.

  16. Lis

    Hi! I use Accespresslite and the recommendations scroller doesn’t work (doesn’t show at all). Does it has something to do with the slider at my homepage (that it can’t show two sliders at the home page)?

    Reply
  17. ashok

    Hi, i am new to WP … i have 2 saved searches (job searches) in my linkedin account, i just want to display the output of those searches in my wordpress website….is there a option to do that….(sorry if this question is not relevant here)

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.