How To Display Twitter Followers Image List
The following snippet displays the Twitter followers image list.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<?php //replace $options['twitter'] with the twitter Username you want to use. ?> <?php $xmlfollowersUrl = 'http://api.twitter.com/1/statuses/followers/'.$options['twitter'].'.xml'; if (file_exists(WP_CONTENT_DIR.'/uploads/twitter_followers.xml')) { $data = unserialize(file_get_contents(WP_CONTENT_DIR.'/uploads/twitter_followers.xml')); if ($data['timestamp'] > time() - 120 * 60) { $twitter_followers = $data['twitter_result']; } } if (!$twitter_followers) { // cache doesn't exist or is older than 10 mins $twitter_followers = file_get_contents($xmlfollowersUrl); // or whatever your API call is $data = array ('twitter_followers' => $twitter_followers, 'timestamp' => time()); file_put_contents(WP_CONTENT_DIR.'/uploads/twitter_followers.xml', serialize($data)); } $dom = new DOMDocument; $s = simplexml_load_string($twitter_followers); $count = 0; echo '<ul class="seguidores">'; foreach($s->user as $follower): if(++$count > 50){ break; } echo '<li><a target="_blank" href="http://www.twitter.com/'.$follower->screen_name.'"><img width="32" height="32" src="'.$follower->profile_image_url.'" alt="'.$follower->name.'" title="'.$follower->name.': '.$follower->status->text.'"/></a></li>'; endforeach; echo '</ul>'; ?> |
Snippet Source/Credit: Snipplr
How To Delete Width And Height Attributes From Image Tag
The following snippet will let you delete both width and height attributes from image tag.
1 2 3 4 5 |
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail' ); if ($image) : ?> <img src="<?php echo $image[0]; ?>" alt="" /> <?php endif; ?> |
Snippet Source/Credit: Stackexchange
How To Define WordPress Template
The following snippet will let you define WordPress template.
1 2 3 4 5 |
<?php /* Template Name: Snarfer */ ?> |
Snippet Source/Credit: WordPress.org
How To Display WordPress Excerpt Dynamic Length
The following snippet display the WordPress excerpt dynamic length.
1 2 3 4 5 6 7 8 9 10 11 12 |
function ms_rp_excerpt($limit) { $excerpt = explode(' ', get_the_excerpt(), $limit); if (count($excerpt) >= $limit) { array_pop($excerpt); $excerpt = implode(' ', $excerpt).'...'; } else { $excerpt = implode(' ', $excerpt); } $excerpt = preg_replace('`\[[^\]]*\]`', '', $excerpt); return $excerpt; } |
Snippet Source/Credit: Snipplr
How To Execute Shortcode From Custom Field
Using the snippet below will let you execute shortcode from custom field.
1 |
<?php echo apply_filters('the_content', get_post_meta($post->ID, 'your_custom_field_here', true)); ?> |
Snippet Source/Credit: Leeboyce.co.uk