Facebook: Like Buttons uses wrong url

I use the digg-digg Wordpress Plugin on this blog and found a annoying error - the like button does not use the correct url. I found out why and how to correct it.

What happened

  • I wrote a new article and watched the preview of it.
  • Digg-Digg showed the buttons on the preview page.
  • I published the article and tried the Like Button.
  • The Like Button did not use the correct url, in my case: juliusbeckmann.de/article-name.html instead of juliusbeckmann.de/blog/article-name.html.

Explained

While watching the preview, die like button send the preview url to facebook. Now facebook tried to fetch the page, but was redirected because the article was not published yet. Facebook "guessed" a url and came up with "juliusbeckmann.de/" what got cached.
Now i published the articled, used the like button, but facebook does not use the new url, they used the old guessed and cached url from the preview.

Solution

Solution is simple: Do not show the facebook like button on preview pages that will not be visibile for facebook.

Hack for Digg-Digg

Hacking Digg-Digg is simple. Open the file "digg-digg.php" and find the function "dd_hook_wp_content".
Now replace this code:

global $wp_query;
$post = $wp_query->post; //get post content

with this code:

global $wp_query;
// Hack - No Digg-Digg on preview pages  by JuliusBeckmann.de
if($wp_query->is_preview){
   return $content;
}
$post = $wp_query->post; //get post content

No related posts.


 
 
 

Die Kommentarfunktion zu diesem Beitrag wurde deaktiviert.