我只想在我的函数中添加此代码。php,以便在我的帖子结束后直接显示。目前,我正在将此代码添加到我的单篇文章中。php,但我想在函数中添加它。php,此代码用于获取各个帐户的所有推文,代码如下
<?php
function parse_twitter_feed($feed, $prefix, $tweetprefix, $tweetsuffix, $suffix) {
$feed = str_replace("<", "<", $feed);
$feed = str_replace(">", ">", $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_feed($twitterFeed, $prefix, $tweetprefix, $tweetsuffix, $suffix);
}
?>