WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Twitter Tools] URL filter (and hashtag setting) not working...? (1 post)

  1. Stephanie Leary
    Member
    Posted 4 years ago #

    I'm trying to use the tweet_blog_post_url filter to display the default permalink structure (http://example.com/?p=n) -- which I'd really like to see as an option in the plugin, but I'm happy enough doing a filter if I can get it to work. This code works when I dump the function's contents into a single.php file and echo the final link, but it doesn't seem to work as a filter:

    function tweet_default_permalink($long_url) {
    	global $wpdb;
    	$long_url = preg_replace("/\/$/","",$long_url); // remove trailing slash
    	$post_name = strrchr($long_url, '/'); // find thing from last slash onward
    	$post_name = substr($post_name, 1); // remove initial slash
    	$postID = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'publish'");
    	$url = get_bloginfo('url')."/?p=".$postID;
    	return $url;
    }
    add_filter('tweet_blog_post_url', 'tweet_default_permalink');

    I'd love to know what's wrong! I searched the web for a while but never found any examples of working filters, only people giving up on the filter and hacking the plugin code.

    In other news, I can't get Twitter Tools to append my hashtag unless I set it individually on each post. It doesn't respect the default at all.

    TT 2.0, WP 2.8.6.

    http://wordpress.org/extend/plugins/twitter-tools/

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 4 years ago by Stephanie Leary
  • This topic is not resolved
  • WordPress version: 2.8.5