Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

social-sharing

Only display link to author social media when it exists [closed]

This is a very simple PHP issue, unrelated to WordPress. You need to check if the value is empty before echoing it. So, store them as variables first: $twitter = get_the_author_meta(‘twitter’, $author_id); $facebook = get_the_author_meta(‘facebook’, $author_id); //etc Then check them before displaying: if(!empty($twitter)) { echo ‘<a title=”Follow me on Twitter” href=”‘.$twitter.'”><img src=”twitter.png” alt=”” /></a>’; } … Read more

Categories functions Tags author-template, functions, social-sharing

Is there a way to change a post’s thumbnail image(s)?

Facebook scrapes your pages for images to go along with the post you share. When it finds an image on the page it will use that. To specify which image exactly you have to use Open Graph tags in the head part of you html page. The og:image tag in particular: <meta property=”og:image” content=”http://graphics.myfavnews.com/images/logo-100×100.jpg” /> … Read more

Categories post-thumbnails Tags post-thumbnails, sharing, social-sharing, thumbnails

How to generate “og:image” meta for Facebook sharing when the image in the post is not featured?

As was already stated, Facebook automatically detects images if the OG image tag is missing. However, in some cases, it might detect other images (e.g. not from your post but from other content). In that case, it can be useful to fetch a list of all images attached to the post and use the one … Read more

Categories facebook Tags facebook, social-sharing

Social sharing post’s shortlink instead of permalink

I very much doubt you can universally “trick” all plugins without touching at least some of some plugin code, but I think your best bet would be filters on the_permalink and post_link, and maybe pre_post_link. Even if you got that working it would be pretty “heavy”. That is, a lot of processing happens before you … Read more

Categories plugins Tags permalinks, plugins, shortlink, social-sharing

Retrieving Google Plus share count with wp_remote_post

I see that the question is 2 years old, but I worked hard two days to find solution of the very same problem and here is my code (for me works 100%). $json_string = wp_remote_request(‘https://clients6.google.com/rpc’, array( ‘method’ => ‘POST’, ‘body’ => ‘[{“method”:”pos.plusones.get”,”id”:”p”,”params”:{“nolog”:true,”id”:”‘.rawurldecode(get_permalink()).'”,”source”:”widget”,”userId”:”@viewer”,”groupId”:”@self”},”jsonrpc”:”2.0″,”key”:”p”,”apiVersion”:”v1″}]’, ‘headers’ => array(‘Content-Type’ => ‘application/json’) )); $json = json_decode($json_string[‘body’], true); if(isset($json[0][‘result’][‘metadata’][‘globalCounts’][‘count’])){ echo intval($json[0][‘result’][‘metadata’][‘globalCounts’][‘count’]); … Read more

Categories google-plus Tags curl, google-plus, social-sharing, wp-remote-post

Get total social share count (Facebook, Twitter, Google+. Pinterest)

Okay. @ialocin made a note about Transients. By some odd reason, I have not come across this yet. Previously, I used to display counts by: jQuery (client side loading) Page caching (when storing counts locally) Cron updating count values And most recently, stored all counts in post meta and updated the meta every 100 loading … Read more

Categories social-sharing Tags social-sharing

How can i disable a plugin for a mobile phone?

There is wp_is_mobile() function to conditionally display (or block) content for mobile users. <?php if (!wp_is_mobile()) : ?> <!– Stuff to hide from mobile users –> <?php endif; ?>

Categories mobile Tags mobile, responsive, social-sharing

Edit Custom Links Menu markup: Making a Social Media Menu with linkable icons

I think you’re using the wrong way, you need customizations for it.This may help you for this. add_filter(‘wp_nav_menu_items’, ‘register_social_links’, 10, 2); function register_social_links($items, $args) { if ($args->theme_location == ‘top-header’) {//Here you can use your menu theme location $items .= ‘<li class=”your-class-name”><a href=”https://www.facebook.com/peakwebsiteservices/” target=”_blank” title=”Facebook: Peak Websites”><i class=”fa fa-facebook-square” aria-hidden=”true”></i></a></li>’; } return $items; } Hope this … Read more

Categories menus Tags html, menus, social-sharing

List repeating share links

There are a couple of problems with your code: You have to close the PHP context, if you want to output plain HTML: function foo(){ ?><strong><?php } Don’t repeat yourself. Always store repeating values in variables or functions. Writing <a href more than once is a bug. Do not use get_the_title() in attributes. Use the_title_attribute( … Read more

Categories functions Tags functions, social-sharing

Share buttons on article footer

Here is a solution that uses genericons. The original code was derived from this question I asked, and answered by toscho, so credit goes to him for the original code that lead to the code in this answer. Check it out here First, download and intall the genericon pack in your theme. Enqueue the genericon … Read more

Categories plugins Tags footer, plugins, posts, social-sharing
Older posts
Newer posts
← Previous Page1 … Page7 Page8 Page9 Next →
+ More

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
Next Page »
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress