WordPress.org

Ready to get started?Download WordPress

Forums

Latest Tweets Widget
[resolved] Any way to 'nofollow' links in tweets? (5 posts)

  1. aerodesigns
    Member
    Posted 6 months ago #

    Thanks for the great plugin!

    I was just wondering if there was any way to enter a 'rel="nofollow"' into links contained within tweets either by editing the main plugin file, or with a filter in functions.php?

    Many thanks!

    http://wordpress.org/plugins/latest-tweets-widget/

  2. timwhitlock
    Member
    Plugin Author

    Posted 6 months ago #

    There are some filters available, see the Other Notes tab
    http://wordpress.org/plugins/latest-tweets-widget/other_notes/

    I think you'll have to render the whole tweet yourself using latest_tweets_render_text, or do some string manipulation on the rendered html afterwards with latest_tweets_render_tweet

  3. aerodesigns
    Member
    Posted 6 months ago #

    Thanks Tim, here's a simple replacement for anyone also searching that adds rel=nofollow after using the 'latest_tweets_render_text' filter:

    $tweet = latest_tweets_render_html('twitusername', 1);
    $newtweet = preg_replace("/href/", 'rel="nofollow" href', $tweet);

    Obviously this doesn't check whether a rel=nofollow already exists, however I presume when the tweet is delivered from Twitter it isn't nofollowed anyway.

  4. Abhik
    Member
    Posted 5 months ago #

    Hi,
    Can you please share the whole code to make the links in there nofollow?

    Tried different approaches, but failed.

  5. Abhik
    Member
    Posted 5 months ago #

    Nevermind, got it working:

    function nofollow_tweets($tweet) {
    	return preg_replace("/href/", 'rel="nofollow" href', $tweet);
    }
    add_filter('latest_tweets_render_tweet', 'nofollow_tweets', 10, 1);
    

Reply

You must log in to post.

About this Plugin

About this Topic