Publicized post results in ugly links on Google
-
Hi!
On and off, I’m experiencing sort of the same problem I used to have with Facebook, where the post that’s been shared doesn’t look like it should. The images are missing, and all I get is a really ugly link.It used to be the other way around. I never had any problems at all with G+, but then it changed a while back. It’s been going on for several months now.
The ugly link looks like this:
https://i.imgur.com/LGJzC1y.pngThis is how it should look:
https://i.imgur.com/SqsxtH8.pngI have basically no plugins installed besides Jetpack and Akismet on my site. It’s also a multisite and my other blog in this network also has this issue.
It rarely happens on FB anymore, thanks to a snippet of code that I found somewhere online. Is it possible this can be changed a bit so I can use it on G+ as well? I really hate these ugly links…
// Issues with sharing posts on Facebook: https://www.passwordincorrect.com/issue-with-sharing-wordpress-posts-to-facebook/ // Add this chunck of code in your functions.php or anywhere else in your theme files. // Register action for post status transitions add_action( 'transition_post_status' , 'purge_future_post', 10, 3); // Check if the new transition is publish, for correctness you could check if $old_status == 'pending', but I want that every post (which is published) is cached again (just to be sure). function purge_future_post( $new_status, $old_status, $post ) { if($new_status == 'publish') { purge_facebook_cache($post); } } // Ping Facebook to recache the URL. function purge_facebook_cache($post_id) { $url = get_permalink($post_id); $fb_graph_url = "https://graph.facebook.com/?id=". urlencode($url) ."&scrape=true"; $result = wp_remote_post($fb_graph_url); }
Maybe it’s my site that has problems with performance issues, but I tried a few months back to install every site into a single site, and the problems continued. Also I’ve tried connecting and reconnecting without any success. It seems to be happening at total random.
- The topic ‘Publicized post results in ugly links on Google’ is closed to new replies.