Title: [Plugin: Tweetbacks] [Patch] Find non-rewritten permalinks
Last modified: August 19, 2016

---

# [Plugin: Tweetbacks] [Patch] Find non-rewritten permalinks

 *  [thefluffanutta](https://wordpress.org/support/users/thefluffanutta/)
 * (@thefluffanutta)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/plugin-tweetbacks-patch-find-non-rewritten-permalinks/)
 * I wanted Tweetbacks to also find links that used WordPress’ default URLs, as 
   if the Permalinks setting hadn’t been changed. For example: mysite.com/blog/?
   p=123. I did this so that my ‘Tweet This’ links could be shorter without using
   a 3rd-party service.
 * Here’s the patch for tweetbacks.php version 1.5:
    [modification of function yoast_get_tweetback()]
 *     ```
       *** 505,510 ****
       --- 505,511 ----
               require_once(ABSPATH . WPINC . '/rss.php');
   
               $permalink = get_permalink($post_id);
       +       $defaultlink = get_option('home') . '/?p=' . $post->ID;
   
               $shorturls = get_post_meta($post_id,"shorturls",true);
               $oldshorturls = $shorturls;
       ***************
       *** 524,529 ****
       --- 525,535 ----
                       $shorturls['permalink'] = $permalink;
               }
   
       +       // Add the raw permalink of the post itself, e.g. /blog/?p=123
       +       if (!isset($shorturls['defaultlink'])) {
       +               $shorturls['defaultlink'] = $defaultlink;
       +       }
       +
               if (!isset($shorturls['tinyurl'])) {
                       $result = $snoopy->fetch("http://tinyurl.com/api-create.php?url=".$permalink);
                       if ($result && strpos($snoopy->response_code,"200") !== false && $snoopy->results!="" && strpos($snoopy->results,"http://tinyurl.com") === 0) {
       ```
   
 * Here’s what I put in comments.php for my theme:
 * `<a href="http://twitter.com/home?status=<?php the_title_attribute();?>:+<?php
   echo get_option('home');?>/%3Fp%3D<?php the_ID(); ?>">Tweet this post</a>`
 * Works a treat.
 * 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [thefluffanutta](https://wordpress.org/support/users/thefluffanutta/)
 * (@thefluffanutta)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/plugin-tweetbacks-patch-find-non-rewritten-permalinks/#post-987621)
 * Sorry, made a typo on first modified line. Should have been this:
 * `+ $defaultlink = get_option('home') . '/?p=' . $post_id;`
 *  [rickybuchanan](https://wordpress.org/support/users/rickybuchanan/)
 * (@rickybuchanan)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/plugin-tweetbacks-patch-find-non-rewritten-permalinks/#post-987630)
 * This would be really useful to have in the default package, as for those with
   short hostnames they’re like pre-shortened URLs with no service needed. Joost?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: Tweetbacks] [Patch] Find non-rewritten permalinks’ is closed
to new replies.

 * 2 replies
 * 2 participants
 * Last reply from: [rickybuchanan](https://wordpress.org/support/users/rickybuchanan/)
 * Last activity: [17 years, 3 months ago](https://wordpress.org/support/topic/plugin-tweetbacks-patch-find-non-rewritten-permalinks/#post-987630)
 * Status: not a support question

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
