8

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( array (...


7

Yes, social counts are a great use case for using transients. Aside from the slow page loading, as you mentioned, this will also help prevent you from blowing through API limits if the external requests are being made on every page load. Let's say you have it set to cache for 30 minutes and the check for cache expiration is occurring when the data is ...


7

There's a reason people say that you shouldn't download free themes from outside of wordpress.org, they might contain hidden surprises In your case, the theme inserts an advertisement at the beginning of the post content div: <div style="position:absolute;top:0;left:-9999px;">Want create site? Find <a href="http://dlwordpress.com/">Free ...


6

Several options: Out-of-the-box plugin If you're using Yoast WordPress SEO, you have a built-in setting for Facebook images. Under your SEO > Social menu, go to the Facebook tab and select an image under "Frontpage settings." You can also set an image as a fallback, for posts that have no featured image, under "Default settings." Other SEO plugins may ...


4

Facebook caches the meta values for performance. So it is currently hosting an old version of the shared URL. You need to use the Facebook debugger, and Fetch new scrap info. This will update the stored meta values of the post. To confirm that it works, I have already fetched new data for the respective URL and this is how it looks when I share it on FB: ...


4

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 you like, or, as you suggest, the first one. The example below ...


4

Put this in your head <?php $fb_image = wp_get_attachment_image_src(get_post_thumbnail_id( get_the_ID() ), 'thumnail'); ?> <?php if ($fb_image) : ?> <meta property="og:image" content="<?php echo $fb_image[0]; ?>" /> <?php endif; ?> To test it out, you don't have to create a new post, just paste your URL in here: https://...


3

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-100x100.jpg" /> ...


3

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 of the page... pretty wild. But ...


3

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":"'....


3

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; ?>


3

Yes. Using CSS won't prevent JS from loading generally but it's more reliable than server side sniffing. Depends on project but I would go with media queries to just hide it or bring it in page's content flow. @media (max-width: 768px) { .sticky-social { display: none; } }


3

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 ...


2

As far as I know, you should be able to include the following code in your theme file somewhere. You would need to upload the appropriate icons. //Facebook Share <a href="http://www.facebook.com/sharer/sharer.php?s=100&p[url]=<?php echo get_permalink() . '&p[title]=' . get_the_title(); ?>"><img src="[facebook icon url]" /></a>...


2

It's assumed that your images are Facebook Image Sharing Compliant in size and quality, and you are trying to share single posttype 'post' only from a single template (single.php), and you are storing your image as post thumbnail. The following code will grab the post thumbnail (size = large) of particular post and put that in the og:image meta tag on the &...


2

This is actually not related to WordPress and applies to any website or blog: When an url is shared for the first time on Facebook, it visits the page to grab the title, image, description, etc. and keeps this info in cache for some time (this is the period referred to as an "unbelievably long time" in the question - by default it seems to be 24h). It won'...


1

How do the websites that are well optimized for sharing and excerpt displays are handling this subject ? They definitely have separate fields for excerpt / share-text etc. This is the only way to be certain what text gets used. These sites also make use of special meta tags in the head to send Facebook, Twitter et al. information about the content that is ...


1

Best way would be to: Create a child theme, so you can still update the base theme Modify header.php or whatever outputs the logo to output your button Add custom CSS to style/position your button (in the child theme obviously)


1

Simply use set_url_scheme() function. $share_image_src = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' ); $share_image_src = set_url_scheme( $share_image_src, 'http' );


1

You would have to put the old link into the url attribute for each of the share buttons. For example: <a href="https://twitter.com/share" class="twitter-share-button" data-url="https://domain.com/old-link" data-via="your_screen_name" data-lang="en">Tweet</a> Twitter also has an attribute called counturl which might be worth looking at. You'll ...


1

You need to replace the URL paths with: <?php the_permalink(); ?> Also consider replacing the title or description text for each button with: <?php the_title(); ?> Here's an example: <!-- Twitter --> <a href="http://twitter.com/share?url=<?php the_permalink(); ?>&text=<?php the_title(); ?>" target="_blank"><...


1

This is the solution. I had the same problem with my Elegant Themes "Divi", but not other themes. I asked and in support forum the answer is in CSS: .stButton .stFb, .stButton .stTwbutton, .stButton .stMainServices { height: 28px !important; } Also, for the count bubble: .stHBubble { height: 22px !important; }


1

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 stylesheet function enqueue_genericon_style() { ...


1

The plugin that you are using has a bug. I would strongly suggest for you to call the plugin author. Here is the bugs; Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in C:\xampp\htdocs\wordpress\wp-includes\functions.php on line ...


1

Within a function or method, the return statement immediately stops the execution of the earlier. Hence the last line never gets interpreted. Switch the order of this: return $social_score; update_post_meta($post_id, '_social_score', $social_score); to this: update_post_meta($post_id, '_social_score', $social_score); return $social_score; Update: You ...


1

I'm not sure if you are using BuddyPress or not, but there is a functionality there using this plugin FollowMe. This would assume you are running a site with some membership capabilities.


1

I decided to use the built in Facebook sharer and Twitter sharer links, as provided on each site. It won't give complete functionality, but it it's perfect for a simple custom icon. Note: This will only work properly within 'the loop' HTML code to be inserted in your page template: <div class="social_icons"> <a href="javascript:window.print()"...


1

Got a solution: Just added functions to call each buttons in the ajax loading JavaScript file. $(document).ajaxComplete(function() { FB.XFBML.parse(); // For Facebook button. twttr.widgets.load(); // For Twitter button. gapi.plusone.go(); // For Google plus button. });


1

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 get to interrupt things.


1

Try copying the following code into your functions.php file. It adds a custom og:image property for the authors with nicenames of michelle-robinson, mystery-man, john-smith, and a default fallback image, respectively. You can easily change this to suit your needs. add_action( 'wp_head', 'wpse_70701_author_image' ); function wpse_70701_author_image() { ...


Only top voted, non community-wiki answers of a minimum length are eligible