How To Add A Logo To A Template
Using the following snippet, you will be able to add a logo to a template.
1 |
<img src="<?php echo get_stylesheet_directory_uri()?>/images/logo.png" alt="My Logo"> |
Snippet Source/Credit: WPSnipp
How to count retweets in full text
Adding the following snippet in your theme’s functions.php file, you will be able to count retweets in full text.
1 2 3 4 5 6 7 8 9 10 |
function tweetCount($url) { $content = file_get_contents("http://api.tweetmeme.com/url_info?url=".$url); $element = new SimpleXmlElement($content); $retweets = $element->story->url_count; if($retweets){ return $retweets; } else { return 0; } } |
Once saved copy and paste the following lines of snippets in your theme’s single.php file:
1 2 |
$rt = tweetCount(get_permalink()); echo "Retweeted ".$rt." times."; |
Snippet Source/Credit: WPRecipes
How To Automatically Link Twitter Usernames In WordPress Posts
Using the following snippet, you will be able to automatically link Twitter usernames in WordPress posts.
1 2 3 4 5 |
function content_twitter_mention($content) { return preg_replace('/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/', "$1@$2", $content); } add_filter('the_content', 'content_twitter_mention'); add_filter('comment_text', 'content_twitter_mention'); |
Snippet Source/Credit: Paulund.co.uk
How To Block Admin For All Users In WordPress
Using the following snippet you will be able to block admin for all users in WordPress.
1 2 3 4 5 6 7 |
add_action( 'init', 'blockusers_wps_init' ); function blockusers_wps_init() { if ( is_admin() && ! current_user_can( 'administrator' ) ) { wp_redirect( home_url() ); exit; } } |
Snippet Source/Credit: WPSnipp
How To Rename WordPress Folder
Using the following snippet, you will be able to rename WordPress folder.
1 2 3 4 |
define ( 'WP_CONTENT_FOLDERNAME', 'public' ); define ( 'WP_CONTENT_DIR', ABSPATH . WP_CONTENT_FOLDERNAME ); define ( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/' ); define ( 'WP_CONTENT_URL', WP_SITEURL . WP_CONTENT_FOLDERNAME ); |
Snippet Source/Credit: Snipplr