10 WordPress Tips to Take You to the Next Level

Join LonePlacebo.com on Facebook!

cookie monster
Are you getting the most out of your WordPress blog or website? Obviously not since you are reading this post, which by the way you shouldn’t forget to share with your friends, family, and neighbor’s cat. The beauty of WordPress lies in its massive scope of possibilities to experiment and create amazing things you’ve never dreamed of. In this post, I will share with you ten incredible tips I’ve come across and really found useful. I hope you discover something new.

  1. How to add an author section in your posts

  2. You’ve just written a fabulously eloquent post called “5 Reasons Why Twitter is Better than Beer Pong.” Things are looking great on Google Analytics, and people are submitting the article to Digg and Stumbleupon in massive numbers. Problem is, no one knows who wrote this Shakespearean masterpiece. Here’s how you can add a simple author section in the bottom of your posts.

    First off, make sure your author bio is completely filled out in your profile page(name, website url, biographical info). Then, proceed to your single.php file. Add the following chunk of code:

    <div id="author-info">
           <div id="author-image">
        	   <a href="<?php the_author_meta('user_url'); ?>"><?php echo get_avatar( get_the_author_meta('user_email'), '80', '' ); ?></a>
           </div>
           <div id="author-bio">
              <h4>Written by <?php the_author_link(); ?></h4>
              <p><?php the_author_meta('description'); ?></p>
           </div>
    </div>
    

    Here, three div’s mark out the structure of your author section. The author-info id boxes the entire content, the author-image id is where your handsome face will sit, and the author-bio id is where your author bio will show. I’ve also included some handy WordPress template tags as well.

    Now that you have the HTML/PHP set up in your single.php file, it’s time to style the author section in your style.css file. Here’s the CSS I used to style my author section:

    #content div#author-info {
    	background: #eaeaec; padding: 10px; margin: 0 0 15px 0;
    	-moz-border-radius: 8px;
    	-webkit-border-radius: 8px;
    	border-radius: 8px;
    	overflow: auto;
            box-shadow: 1px 1px 12px #2D1D1D;
            -moz-box-shadow: 1px 1px 12px #2D1D1D;
            -webkit-box-shadow: 1px 1px 12px #2D1D1D;
    }
    	#content div#author-info div#author-image {
    		float: left; margin: 0 10px 5px 0; border: 5px solid #DCDCE1;
    	}
    

    Here, I used some wicked-cool CSS3 box shadow effects that probably won’t impress you. Feel free to use it on your blog.

    Source: Line 25

  3. How to Delay RSS Feed Publication

  4. Oftentimes, you finish a post and hit publish. The next day, you find out that something is terribly wrong. For instance, you mistakenly quoted the Pope as being the person who you played golf with last week rather than your friend Poppy. Sure, you can quickly edit the mistake but that will not do you any good for your RSS feed readers. With your credibility forever tarnished, all hope is lost. Right?

    Luckily, WPEngineer has a solution for you. Simply add this code to your functions.php file:

    /**
     * puplish the content in the feed later
     * $where ist default-var in WordPress (wp-includes/query.php)
     * This function an a SQL-syntax
     */
    function publish_later_on_feed($where) {
    	global $wpdb;
    
    	if ( is_feed() ) {
    		// timestamp in WP-format
    		$now = gmdate('Y-m-d H:i:s');
    
    		// value for wait; + device
    		$wait = '5'; // integer
    
    		// http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
    		$device = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR
    
    		// add SQL-sytax to default $where
    		$where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait ";
    	}
    	return $where;
    }
    
    add_filter('posts_where', 'publish_later_on_feed');
    

    This code will delay the publishing of your latest post to RSS feeds by 5 minutes. Of course, you can adjust that span of time by changing line 14 above.

  5. How to Add Hotlink Protection to your site

  6. Content thieves exist on the Internet. (NO WAY!) Don’t believe me? Then you should check your site for copycat offenders at Copyscape.com . Whereas there is no sure way to directly remove this plagiarized content, you can at least deter some thieves by using this hotlink protection method in your .htaccess file located in your root directory:

    Make a backup of your .htaccess file before proceeding! Trust me! Don’t cry to me about it in the comments section below if you forget. :(

    #Begin Hotlink Protection
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yoursite\.com/ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !google\. [NC]
    RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
    RewriteCond %{HTTP_REFERER} !msn\. [NC]
    RewriteCond %{HTTP_REFERER} !yahoo\. [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.feedburner.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://feeds.feedburner.com/yoursite$ [NC]
    RewriteRule .*\.(jpe?g|gif|bmp|png|jpg)$ /images/nohotlink.jpe [L]
    #End Hotlink Protection
    

    I highlighted the three lines you need to change above. So far, this method has worked brilliantly for me, and also not so brilliantly. Before, I did not include the feedburner code, and thus all of my images in my RSS Feed began displaying my hotlink image, which by the way looks like this:

    nohotlink

    Intimidating? I thought so. Please use this with caution though, especially since you are dealing with the .htaccess file.

    I no longer enable hotlink protection on this site due to its inconsistency and tendency to replace images on this site with the hotlink image. If you have a better method, please feel free to share them in the comments section below.

    Source: David Airey

  7. Read More link jumps to top of post page

  8. By default, the <!--more--> tag will send readers to the location of the tag on the post. Alternatively, you can have the more link send readers to the top of the post page instead. Simply, add this code to your functions.php file:

    function remove_more_jump_link($link) {
    $offset = strpos($link, '#more-');
    if ($offset) {
    $end = strpos($link, '"',$offset);
    }
    if ($end) {
    $link = substr_replace($link, '', $offset, $end-$offset);
    }
    return $link;
    }
    add_filter('the_content_more_link', 'remove_more_jump_link');
    

    Source: WordPress Codex

  9. Prevent WordPress from replacing code snippets with “normal” quotes

  10. Imagine my angst when I sat in front of my pathetic Gateway laptop wondering why the code I used from a site doesn’t seem to work when I paste it into my files? I obviously made no errors since I’m a coding god, so it must be the Internet’s fault right?

    By default, WordPress replaces quotes in code snippets you copy and paste from somewhere and converts them to “curly” quotes instead of the “normal” quotes. To solve this, paste the following line of code into your functions.php file:

    <?php remove_filter('the_content', 'wptexturize'); ?>

    Source: WPRecipes

  11. Display Total Number of SQL Queries on Your Blog

  12. Queries are evil. They slow down your site as you begin to accumulate more, which can negatively effect the user experience. In fact, Google agrees too. The first step to lowering queries is to know how many you actually have. Simply paste the following line of code somewhere on your site. I prefer going after the footer.php file.

    <?php if (is_user_logged_in()) { ?>
        <?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds.
    <?php } ?>
    

    If you want this to be publicly shown, simply remove lines 1 and 3.

  13. Split posts into separate pages

  14. This tip is quite handy when you are dealing with lengthy posts, especially those that contain a lot of pictures. To reduce the possibility of people jumping ship as they wait for your “1,000,000,000,000 Pictures of Funny Cats” epic post to load, add this tag to any section of your article you want to split into a separate page:

    <!--nextpage-->

    Some themes may not support this. You can check by locating this code snippet in your single.php file:

    <?php wp_link_pages(); ?>

    Source: WordPress Codex

  15. Display Google Adsense Between Blog Posts

  16. According to some people who like to call themselves “SEO’s”, placing Google Adsense ads or any ads in general between your first and second post has been found to increase your CTR. Here’s how to do it.

    • Go to your index.php file
    • Locate this code snippet:
    •         <?php if (have_posts()) : ?>
      	<?php while (have_posts()) : the_post(); ?>
      
    • Add this code before it:
    • <?php $count = 1; ?>
      
    • Next, locate this code snippet:
    • <?php endwhile; ?>
      
    • Add this before it:
    • <?php if ($count == 1) : ?>
      – Insert your Google AdSense code here –
      <?php endif; $count++; ?>
      

      Just make sure you insert your Google ad code in line 2 as shown above.

  17. Change the Size of the Post Box

  18. By default, the WordPress post box(where you write new posts) is set to 10 lines. To adjust this value to your liking, go to Settings>Writing. On the first line that says “Size of the post box,” simply replace the default value to your preferred box size. If you’re one of those people who rarely looks at the Settings categories, this may be very useful.

  19. Display RSS FeedBurner Subscriber or Twitter Follower Count in Plain Text

  20. Tired of displaying your abysmal RSS Feed reader and Twitter follower count with these guys?

    chicklet

    LonePlacebo.com's actual RSS Feed and Twitter follower count.


    By displaying these chicklets as plain text instead, this opens up new avenues for you to customize the look like never before. The technique I’m about to show you requires you to create two files you will need to upload to your theme’s folder.

    Display RSS Feed Reader Count

    The first file you will need to create is for the RSS Feed reader count. Name it feed.php and paste the following inside it:

    <?php
    //get cool feedburner count
    $whaturl="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=Feed Here";
    
    //Initialize the Curl session
    $ch = curl_init();
    
    //Set curl to return the data instead of printing it to the browser.
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    
    //Set the URL
    curl_setopt($ch, CURLOPT_URL, $whaturl);
    
    //Execute the fetch
    $data = curl_exec($ch);
    
    //Close the connection
    curl_close($ch);
    $xml = new SimpleXMLElement($data);
    $fb = $xml->feed->entry['circulation'];
    //end get cool feedburner count
    
    echo $fb;
    
    ?>
    

    Remember to edit line 3 above where it says Feed Here and replace it with your the name of your feed. In other words, the name that comes after the “http://feeds.feedburner.com/” in your feed address is your feed name. Also, you must enable the Awareness API in Feedburner, which can be found under the Publicize tab. By default, it is disabled. The feed.php file should be placed inside your active theme’s folder.

    To display the feed count on your site, insert the following code in any of your theme’s files such as your sidebar.php(if you have one):

    <?php include("feed.php"); ?>
    

    Display Twitter Count

    Same idea will apply for showing your Twitter count. Name the second file twitter.php and insert the following code inside:

    <?php
    $tw = get_option("twitterfollowerscount");
    if ($tw['lastcheck'] < ( mktime() - 3600 ) )
    {
    $xml=file_get_contents('http://twitter.com/users/show.xml?screen_name=Feed here');
    if (preg_match('/followers_count>(.*)</',$xml,$match)!=0) {
    $tw['count'] = $match[1];
    }
    $tw['lastcheck'] = mktime();
    update_option("twitterfollowerscount",$tw);
    }
    echo $tw['count'];
    ?>
    

    Don’t forget to edit line 5 with your Twitter username. Place the file in your active theme’s folder. Include the following code to display the Twitter count:

    <?php include("twitter.php"); ?>
    

    Source: Blogussion

I hope you found something useful to use on your own WordPress blog or site. Share some of your favorite WordPress tips or hacks in the comments section below!

Related posts:

  1. 5 Solutions to Common WordPress Problems
  2. Yet Another SEO Plugins for WordPress List
  3. 4 Ways to Maximize Your WordPress.com Blog
  4. How to Customize your WordPress Admin Area
  5. How to Install MAMP on OS X for Local WordPress Theme Development

Last updated on:

August 3, 2010 at 6:44 pm

Hide

Written by Tony Hue

Tony Hue is a second-year college student majoring in Business Administration. During his free time, he enjoys watching hilarious viral videos of cats and blogging excessively to a nonexistent audience. You can follow Tony on Twitter or join the LonePlacebo Facebook Page .

Join the conversation!

12 comments to “10 WordPress Tips to Take You to the Next Level ”

Speak up!

(required)*

(required but will not be published)*


CommentLuv Enabled