WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Twitter Tools] Using Ugly Permalinks in tweets (3 posts)

  1. I'm having a serious case of the brain farts.

    In THEORY I know that I should be able to use a function filter to have Twitter Tools use ugly permalinks in tweets (to force shorter urls and yet keep 'branding').

    Since I KNOW I'm way short on sleep, does this look right in theory?

    // Add hook for Twitter Tools URL shortening filter
    add_filter('tweet_blog_post_url','makeShortURL');
    
    // Function to make the short URL
    function makeShortURL($url) {
      global $post;
      $shortpost = $post->ID;
      $shortpost = "http://domain.com/" . $shortpost;
      return $shortpost;
    }
  2. You'd need a plugin to map http://domain.com/123 to the post, but yes, that should work.

  3. Doy. So I added in a p?= in there ;)

    // Add hook for Twitter Tools URL shortening filter
    add_filter('tweet_blog_post_url','makeShortURL');
    
    // Function to make the short URL
    function makeShortURL($url) {
      global $post;
      $shortpost = $post->ID;
      $shortpost = "http://domain.com/p?=" . $shortpost;
      return $shortpost;
    }

    And that kicks back domain.com/p?= ... dang it. $post->ID is wrong.

Topic Closed

This topic has been closed to new replies.

About this Topic