Employee Linkedin Icon and Link


#1

When adding and employee, under Employee info there is the option to add Position, Twitter, Google Plus, and Facebook but not Linkedin.

Using this post’s instructions (https://athemes.com/forums/topic/link-and-icon-for-linkedin/#post-138629) I was able to perform the following steps:

Toolset > Dashboard > Employees > Employee info > Add New Field - add Linkedin.

Now Linkedin and a URL field are listed under Employee info, however, entering a Linkedin URL (or any URL) does not display the Linkedin icon with link on the live site.

The other post was way too vague about registering, unregistering and requiring. The links about each only explained about Wordpress native widgets, but not parent theme widgets. From what I can tell, what’s needed is which files to edit and code to use to unregister (and which widget to unregister), register (and where to name the new widget something different), and lastly which file to edit to and code to add to require the new widget. I hope this makes sense. Thanks!


#2

Hello there,

Please add these code into your child theme’s functions.php:


/*
 * Requiring employee widget file from childtheme
 */
require get_stylesheet_directory() . "/widgets/fp-employees.php";

/*
 * Unregistering default employee widget
 */
function perth_child_remove_employees_widget() {
	unregister_widget('Perth_Employees');
}
add_action( 'widgets_init', 'perth_child_remove_employees_widget' );

/*
 * Registering new widget
 */
function perth_child_register_new_widget(){
  register_widget( 'Perth_Child_Employees' ); // Widget class name
}
add_action( 'widgets_init', 'perth_widgets_init' );

Create a new folder in your child theme and name it as “widget”. Then copy/paste fp-employees.php file from main theme into it. Edit this file in your code editor application. To avoid error due to duplication of class name, take a look at the class name definition at top line:


class Perth_Employees extends WP_Widget {

Rename Perth_Employees to Perth_Child_Employees.

To display the new custom field value, find this line:


$link  = get_post_meta( get_the_ID(), 'wpcf-custom-link', true );

Add this code right after that line:


$linkedin  = get_post_meta( get_the_ID(), 'wpcf-linkedin', true );

Adjust wpcf-linkedin with a slug name you specified in custom field editor.

Then find the following code block where the Google Plus profile link is defined:


<?php if ($google != '') : ?>
<div class="svg-container employee-svg">
	<?php perth_svg_1(); ?>
	<a href="<?php echo esc_url($google); ?>"><i class="fa fa-google-plus"></i></a>
</div>
<?php endif; ?>

Then add the following code:


<?php if ($linkedin != '') : ?>
<div class="svg-container employee-svg">
	<?php perth_svg_1(); ?>
	<a href="<?php echo esc_url($linkedin); ?>"><i class="fa fa-linkedin"></i></a>
</div>
<?php endif; ?>

I hope this reply helps.

Regards,
Kharis


#3

Thank you for responding Kharis. I followed each step you provided, added code to fp-employees.php and loaded it to the widgets folder in the child theme. Also added code to the child’s functions.php file and loaded it.

The Linkedin URL entered into the new Linkedin field under Employee info of the Employees plugin and saved. The Emploees widget is being used on the Home page, but the Linkedin icon and link still don’t display on the live site. If it helps to have the site this is on is at http://www.ibismoneymanagment.com.php56-22.dfw3-1.websitetestlink.com/

The Employees widget is on home page. To see it live, scroll down to the Our Founder section. The Facebook icon and link show up, but not Linkedin. Can you tell why?

Thanks again!


#4

Hello there,

Thank you for the followup!

From your site’s dashboard, please navigate to Toolset > Post Fields > Employee info > expand your LinkedIn fields settings. Then take a screenshot of it. Then upload it to the free file hosting service like Google Drive, Dropbox, cloudup.com or the other one which you prefer. Please share its URL here, so I can take a look.

Please also share the fp-employees.php code of child theme here and share the link into it here, so I can troubleshoot it.

Regards,
Kharis


#5

fp-employees.php code link: https://gist.github.com/anonymous/5e8ed4c748bcaee768bfbe8ace2b6612

Linkedin fields settings: https://www.dropbox.com/s/3zvs182narkn60s/Linkedin-Settings.png?dl=0

Please let me know if you need anything further. Thank you!


#6

Hello there,

It looks like there is something wrong in my code. Sorry. :frowning: I am looking into it again. I will update you ASAP. Please be patience.

Regards,
Kharis


#7

Hello there,

Please replace the code which I suggested you paste into the child theme’s functions.php with this one:


/*
 * Requiring employee widget file from childtheme
 */
require get_stylesheet_directory() . "/widgets/fp-employees.php";

/*
 * Unregistering default employee widget
 */
function perth_child_remove_employees_widget() {
	unregister_widget('Perth_Employees');
}
add_action( 'widgets_init', 'perth_child_remove_employees_widget', 9999 );

/*
 * Registering new widget
 */
function perth_child_register_new_widget(){
  register_widget( 'Perth_Child_Employees' ); // Widget class name
}
add_action( 'widgets_init', 'perth_child_register_new_widget' );

Then edit the widgets/fp-employees.php file of child theme. Replace this line:


function perth_employees()

with:


function __construct() 

Now you should edit your page and update the employee widget.

Regards,
Kharis


#8

I replaced the new functions code with the above. The result was that the plugin no longer displayed on the home page, leaving that section blank. Removing 9999 brought back the plugin displaying on the front end, but still no Linkedin icon/link displays.

Check out the site at demo5.juristheme.com

The Employees widget is on home page. To see it live, scroll down to the Legal Team section. What else can it be?


#9

Hello there,

As the widget class name is different, you should re-insert the widget and update your page. Otherwise, it still loads the old one with no content be displayed.

Regards,
Kharis


#10

Just to clarify, when you say “re-insert widget”, do you mean un-register and re-register the child theme’s Perth_Child_Employees widget? Thank you!


#11

Sorry for confusion.

I mean, you should log into your site admin area (WP dashboard). Then edit the page where your employee widget was inserted into. Remove it, then insert a new employee widget and update your page.

Regards,
Kharis


#12

You’re a rock star! It works. Thank you so much for your help and persistence :slight_smile:


#13

You are always welcome here.

I am marking this thread as resolved. So please let us know in a new topic if you have any further questions, or if we can provide you with any other assistance.

If you enjoy our theme and services, please consider to rate our Perth theme here. We would highly appreciate it if you do so.

Have a nice day!

Regards,
Kharis


#14

Hi! I did all the steps which Kharis mentioned, asked the developer to change functions.php. He did it but didn’t change anything. Linkedin icons didn’t appear.
Furthermore, I had 4 employees in the row before and not now http://joxi.ru/Y2LzlW9C9G33jr
Any tips? http://joxi.ru/E2pE3wys9JOO8A
The page https://blockchain.rlp.li/


#15

Hello there,

Have you re-inserted the widget?

Regards,
Kharis


#16

Yes, I did. And I tried with this widget at the another page — the same result.

But I have this problem on the employee page https://prnt.sc/l02b7h "

|Template|Archive|Views|Forms| Your theme’s template file for displaying Employee items is missing custom fields.|"


#17

Hello there,

That actually only warns developer in case the value of the field isn’t called from the template of single employee. In Perth’s Employee, that doesn’t really needed as we use it in the widget. Please double check your widget’s file and ensure the new LinkedIn field’s value is properly printed.

Regards,
Kharis