WordPress.org

Ready to get started?Download WordPress

Ideas

Filter hook for RSS Widget Item Titles and Content

  1. Vlad Lasky
    Member

    12345

    I am using the RSS Widget to display Twitter tweets in the sidebar of my Blog.

    For those that don't know, you can create an RSS feed from a Twitter Account using the following URL:

    http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=TwitterAccountName

    One annoying thing is that that Twitter prefixes every tweet with the name of the Twitter account. i.e. the RSS widget will display:

    *TwitterAccountName: Latest Tweet
    *TwitterAccountName: Previous Tweet
    *TwitterAccountName: ...

    This prefix is redundant as I have already described this in the RSS Widget title setting.

    I would like to remove the Twitter account name prefix by creating a filter, but the WordPress standard RSS Widget has no filter hook.

    It would be really easy to add one and I propose the name s 'widget_rss_item_title' and 'widget_rss_item_content'

    These could either accept one parameter - a string containing the RSS text, or two parameters - a string containing the RSS text and a string containing the RSS widget title. That way, the filter could be written to target some RSS widgets but not others.

    Here is an example of how it would work in my case:

    <?php
        function filter_twitter_prefix($rss_item_title)
        {
            return preg_replace('/^TwitterAcctName: */i', '', $rss_content);
        }
        add_filter( 'widget_rss_item_title', 'filter_twitter_prefix' );
    
    ?>
    Posted: 2 years ago #
  2. Binary Options
    Member

    12345

    Hei, you can use this function:


    function wp_echoTwitter($username){
    include_once(ABSPATH.WPINC.'/rss.php');
    $tweet = fetch_rss("http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1");
    echo $tweet->items[0]['atom_content'];
    }

    <?php wp_echoTwitter($usernamer); ?>

    Posted: 2 years ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    5 Votes
  • Status

    This idea is under consideration