Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

this code is working perfect for me, but just want to know, how can i bring this after my post, currently all my tweets are coming before the post, how can i make it before the post??

    function parse_twitter_feed($feed, $prefix, $tweetprefix, $tweetsuffix, $suffix) {
  $feed = str_replace("&lt;", "<", $feed);
  $feed = str_replace("&gt;", ">", $feed);
  $clean = explode("<content type=\"html\">", $feed);

  $amount = count($clean) - 1;

  echo $prefix;

  for ($i = 1; $i <= $amount; $i++) {
    $cleaner = explode("</content>", $clean[$i]);
    echo $tweetprefix;
    echo $cleaner[0];
    echo $tweetsuffix;
  }

  echo $suffix;
}

function the_twitter_feed($username) {
  // $username = "Mba_"; // Your twitter username.
  $limit = "5"; // Number of tweets to pull in.

  /* These prefixes and suffixes will display before and after the entire block of tweets. */
  $prefix = ""; // Prefix - some text you want displayed before all your tweets.
  $suffix = ""; // Suffix - some text you want displayed after all your tweets.
  $tweetprefix = ""; // Tweet Prefix - some text you want displayed before each tweet.
  $tweetsuffix = "<br>"; // Tweet Suffix - some text you want displayed after each tweet.

  $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=" . $limit;

  $twitterFeed = get_transient($feed);
  if (!$twitterFeed) {
    $twitterFeed = wp_remote_fopen($feed);
    set_transient($feed, $twitterFeed, 3600); // cache for an hour
  }
  if ($twitterFeed)
    parse_twitter_feed($twitterFeed, $prefix, $tweetprefix, $tweetsuffix, $suffix);
}
function append_the_content($content) {
    $content .= the_twitter_feed(get_option('tweetID'));
       return $content;
}
add_filter('the_content', 'append_the_content');

add_action('admin_menu','tweet_fetch');

function tweet_fetch(){
add_options_page('Tweet','Tweet', 8, 'tweet', 'tweet_fetcher');
}
function tweet_fetcher(){
?>
<h2>Tweet Fetcher options</h2>
<form method='post' action='options.php' style='margin:0 20px;'>
<?php wp_nonce_field('update-options'); ?>
<p>Twitter UserID:<input type="text" name="tweetID"  value="<?php echo get_option('tweetID'); ?>" <?php echo get_option('tweetID'); ?> />
</p>
<input type='hidden' name='action' value='update'/>
<input type='hidden' name='page_options' value='tweetID'/>
<p class='submit'>
<input type='submit' name='Submit' value='Update Options &raquo;'/>
</p>
</form>
<?php
}
share|improve this question
1  
There is no plugin header, no action hooks, actually there isn't even anything that shows me that you tried to do it. google.com/… –  Horttcore Dec 13 '10 at 9:10
    
pluginn header i have not copy pasted over here, and what is action hook, this plugin works if i use shot-code, but i just wanna have a backend –  ntechi Dec 13 '10 at 9:18
    
hey now i modified the code again, the options is also coming under settings options, see my original answer for the code, but the tweets are not coming please can any one help me in this –  ntechi Dec 13 '10 at 11:01
    
Might want to start here: codex.wordpress.org/Writing_a_Plugin –  t31os Dec 13 '10 at 11:38
    
i saw that, and learned from there, but i just wanna know whats wrong in my code now??? –  ntechi Dec 13 '10 at 11:43
show 2 more comments

1 Answer

up vote 0 down vote accepted

I'm not completely sure what you want, but I noticed with position that echo not always give the right position try to build up a large string and then echo the complete results or just return the results.

like this:

$output .= echo $prefix; $output .= echo $tweetprefix; $output .= echo $cleaner[0]; $output .= echo $tweetsuffix; $output .= echo $suffix;

return $output

if you want to do it with echo use comma's to seperate the strings like this:

echo $string1, $string2, $string3, etc.

share|improve this answer
    
thanks but already its done –  ntechi Jan 12 '11 at 7:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.