The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Digg Digg
Shares lost after URL redirect (3 posts)

  1. Ashley Faulkes
    Posted 3 years ago #

    This is not a problem with DiggDigg so much as a question on where in the code to make a change.

    After changing my permalink structure and putting 301 redirects in htaccess file, the share counters for DiggDigg are back to zero - the shares are only counted on the old URL obviously

    There are some posts on how to fix this, but I can't find the place in the current DiggDigg code where I could put a universal fix for this to change the URL being sent to the social media sites for the share count.

    Any help would be appreciateed


  2. Per Søderlind
    Posted 2 years ago #

    Here's a hack I made:

    function get_soderlind_permalink($permalink, $post, $leavename) {
      // Code from: http://encosia.com/preserving-social-sharing-counters-through-a-url-change/
      // Old permalink: /archives/%year%/%monthnum%/%day%/%postname%/
      // New permalink: /%postname%/
      //  Changed URL structure from /archives/yyyy/mm/dd/slug to /slug on
      //  1/12/2013. This ensures older posts still present the old URLs
      //  to Digg Digg so that share counts are maintained.
    	// only run when get_permalink is called from dd_hook_wp_content
    	if ( function_exists('wp_debug_backtrace_summary') && stristr(wp_debug_backtrace_summary(), 'dd_hook_wp_content') !== FALSE) {
      		$url_change_date = strtotime( "12.1.2013" ); // use a date format strtotime understands. see notes at http://php.net/manual/en/function.strtotime.php
      		$post_date = strtotime( get_the_date( ) );
    		if ( $post_date < $url_change_date ) {
    			$url_date_prefix = sprintf("/archives/%s/%s/%s", date( "Y", $post_date ),  date( "m", $post_date ), date( "d", $post_date ));
    			$permalink = str_replace( site_url(), site_url() . $url_date_prefix, $permalink );
    	return $permalink;
    add_filter( 'post_link','get_soderlind_permalink', 20, 3 )
  3. Per Søderlind
    Posted 2 years ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Digg Digg
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic