[Plugin: Sociable] Using shorter URLs for TwitThis
-
Warning: I taught myself coding from looking at the source. I’m probably doing something wrong here. If not wrong… inefficient, at least.
The problem: Really long URLs can eat up into your tweet. Additionally, you have the problem of the same words from the title being repeated in the URL. Redundant, like Duran Duran Duran.
The solution: using “ugly” permalinks (example.com/&p=34 ) There probably is a way to use a link shortener, but why go to that extent when there’s a built in short URL in WP. Unless your URL is somethingreallyreallylong.com/anevenlongerblogtitle/
Step 1: Changing the link
Open wp-content/plugins/sociable.php and find the declaration for TwitThis. Change the second line to
'url' => 'https://twitter.com/home?status=TITLE https://example.com/?p=POSTID',
There’s probably a better way to replace https://example.com with a variable(?), but I wouldn’t know. You could customize the status to include an @YourTwitterId, but hash tags don’t seem to work, for some reason.Step 2: Defining POSTID
Now, you need to define POSTID. Scroll down to `// Load the post’s data
and add
$postid = $post->ID;` on a new line after the $blogname definition.
Next, scroll down to `$url = str_replace(‘PERMALINK’, $permalink, $url);
` and add this line below it:
$url = str_replace('POSTID', $postid, $url);
If you update the plugin, be sure you back up the changed file, and make the changes to your new file.
- The topic ‘[Plugin: Sociable] Using shorter URLs for TwitThis’ is closed to new replies.