Written in response to Twitter feed plugin displays 1 feed, would like 10 per account:
I've been programming PHP and WordPress for several years. View my website, http://wpCodeSnippets.info, for some examples.
|Answers Given:||18 (see them all)|
|Prize Money Earned:||$70|
|Questions refunded:||0 (see all?)|
|Is a top asker (has the power to vote on anything):|
|Subscribes to all the discourse posted to the site?:||No|
|Netvotes this month (upvotes minus downvotes):||0|
|Netvotes of all time (upvotes minus downvotes):||0|
|Joined the site:||April 19, 2011|
Luke America's upvoted answers:
This member has no downvoted answers
Answers given to these questions:
- Upload >58meg get HTTP/IO error WP3.51Multisite host LinuxGoDaddy Winner!
- menu items can't be added in wordpress
- UPDATE: What if the circle doesn't stop spinning?
- Need an Accordion and Tab Shortcode
- Simple Facebook Connect | CSS in Array
- How do I extract part of a URL?
- Hide sidebars
- CSS question: how do I do link pseudo classes as inline styles? Winner!
- Background image placement
- Change width & change widgets
- Alter child permalinks to show within root.
- Change width on blog post & widget Winner!
- Custom permalinks for pages break(404) after saving a page Winner!
- What plugin is this website using? Winner!
- Twitter feed plugin displays 1 feed, would like 10 per account
- .htaccess file, redirects, and making dev site live Winner!
- WebFonts not working in IE still Winner!
- mySQL query: remove first IMG tag and surrounding link from DB
Luke America has not voted on any questions
Luke America has not asked any questions
This member has not made any recommendations. If you are one of the top experts, please offer one now!
Luke America's discourse:
Written in response to Show tweet count as text for posts :
You could cache the data in a file on your server or in a WP "transient" database table.
Or, you could use cURL with its built-in page retrieval cache to reduce the probability of setting off flags. With all of these solutions though, you will not get the very lastest data ... but mildly time-delayed.
I was just about to submit my solution when Baki Goxhaj replied. I didn't want to counter his incredibly fast response, but I knew there was a high probability you'd eventually start getting these sporadic 403's.
Try using this function instead of file_get_contents(). Just put it in your theme's functions.php file and call it instead of file_get_contents(). Once you're flag is cleared with their service, it should work in perpetuity. But, using a database transient is a better solution.
function curl_get_contents($url, $fresh_connect=false)
$result = false;
$url = str_replace(' ', '%20', $url);
$handle = curl_init($url);
if (is_resource($handle) === true)
curl_setopt($handle, CURLOPT_FAILONERROR, true);
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_FRESH_CONNECT, $fresh_connect);
$result = curl_exec($handle);