-
Hi,
I only need the LinkedIn share-button on my page. So I modified the sharepage.php. But now the LinkedIn share-button is not working. Is there anything wrong on my code?
function lifecoach_encodeURIComponent($str) { $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')'); return strtr(rawurlencode($str), $revert); } $pageurl = lifecoach_encodeURIComponent(get_permalink( get_the_ID() ) ); $title = lifecoach_encodeURIComponent(get_the_title( get_the_ID() ) ); $source =lifecoach_encodeURIComponent(get_bloginfo('name')); $socials = array( "linkedin" => 'https://www.linkedin.com/shareArticle?mini=true&url={articleUrl}&title={articleTitle}&summary={articleSummary}&source={articleSource}'.$pageurl.'&title='.$title.'&source='.$source ); ?> <!-- SHARE FUNCTIONS ================================================== --> <ul class="qt-sharepage qt-content-primary"> <li class="hide-on-med-and-down"> <i class="qticon-share qt-shareicon qt-content-primary-dark"></i> </li> <li> <a>" data-position="right" data-sharetype="linkedin" data-name="Share" data-width="600" data-height="500" target="_blank" href="<?php echo esc_url($socials['linkedin']); ?>"> <i class="qticon-linkedin"></i> </a> </li> <?php
Thanks a lot in advance!
regards,
Rabea
- This topic was modified 3 years, 9 months ago by themes2go.
Hello Rabea,
as I can see your code is messed up.
Even if this kind of customization goes out of the support territory, I’ve done the edit for you.Copy, paste and save the code below on your sharepage.php and you should be ready to go.
<?php /* Package: LifeCoach Description: SHARE FUNCTIONS Version: 1.2.2 Author: Themes2Go Author URI: http://themes2go.xyz */ function lifecoach_encodeURIComponent($str) { $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')'); return strtr(rawurlencode($str), $revert); } $pageurl = lifecoach_encodeURIComponent(get_permalink( get_the_ID() ) ); $title = lifecoach_encodeURIComponent(get_the_title( get_the_ID() ) ); $source =lifecoach_encodeURIComponent(get_bloginfo('name')); $socials = array( "linkedin" => 'https://www.linkedin.com/shareArticle?mini=true&url='.$pageurl.'&title='.$title.'&source='.$source ); ?> <!-- SHARE FUNCTIONS ================================================== --> <ul class="qt-sharepage qt-content-primary"> <li> <a class="qt-popupwindow qt-sharelink waves-effect qt-tooltipped" data-tooltip="<?php echo esc_attr__("Share on Linkedin", "lifecoach"); ?>" data-position="right" data-sharetype="linkedin" data-name="Share" data-width="600" data-height="500" target="_blank" href="<?php echo esc_url($socials['linkedin']); ?>"> <i class="qticon-linkedin"></i> </a> </li> <?php /** * Requires QT LoveIt plugin */ if(function_exists('qtli_post_like')){ $post_id = get_the_ID(); $vote_count = get_post_meta($post_id, "qtli_votes_count", true); ?> <li> <a href="#" class="qt-btn-primary qt-sharelink waves-effect qt-loveit-link <?php if( true === qtli_hasAlreadyVoted($post_id) ) { ?>qt-disabled<?php } ?> qt-tooltipped" data-tooltip="Love" data-position="right" data-post_id="<?php echo esc_attr($post->ID); ?>"><i class="qticon-heart"></i> <span class="qtli count"><?php echo esc_attr($vote_count); ?></span> </a> </li> <?php } ?> </ul> <!-- SHARE FUNCTIONS ================================================== -->
Have a nice day 🙂
Hi,
thanks for your fast replay. I tried the code and on page it looks good but if I try to share a post on LinkedIn I get the message: “Something went wrong”
This error comes when your website can’t connect properly with LinkedIn.
Are you working on a local or remote environment?It could be also something messed up on the code so for this I’ll send you a zip file containing the sharepage.php edited and tested few moments ago on our online demo.
https://www.themes2go.xyz/helpdesk/wp-content/uploads/2021/04/sharepage.php_.zip
Download, extract the file and overwrite the original one if you are using the main theme, otherwise place it to the child theme folder.
Now it’s working! Thank you so much!
Have a nice day!
regards,
Rabea
The topic ‘Share-Button’ is closed to new replies.