How To Remove Existing Information From WordPress
The following snippet will let you remove existing information from WordPress.
1 2 3 4 5 6 7 8 9 10 |
function add_myExtra_ContactMethod( $contactmethods ) { // Add Twitter $contactmethods['twitter'] = 'Twitter'; // Add Facebook $contactmethods['facebook'] = 'Facebook'; //Remove Jabber / Google Talk unset($contactmethods['jabber']); return $contactmethods; } add_filter('user_contactmethods','add_myExtra_ContactMethod',10,1); |
Snippet Source/Credit: readers-cafe.net
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
Displaying 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 Display Twitter Followers Image List
Using the following snippet, one can display 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