This guest post was written by Hayes Potter, the 13 year old web developer and designer that gives webmasters tips on protecting their website from common hacking techniques. If you have webmaster or WordPress knowledge and are interested in writing a post for Hack WordPress, please contact us.

Adding A Side Blog

  1. Pick a desired category and add it in your blog (i.e. category “Side Blog”)
  2. Implement the following code into your “Functions.php” in your theme’s directory:

<?php
function asidesFilter($query) {
if($query->is_feed || $query->is_home || $query->is_ search) {
$query->set(’cat’, ‘-115?);
}return $query;}
>add_filter(’pre_get_posts’, ‘asidesFilter’);>
?>

(Notice the number 115 is the category ID number for the chosen category. Yours will be different.)

3. Then add the following into your “sidebar.php” file in your theme’s directory:
<h3>Side Blog
<a href=”FEED URL” title=”My Side blog's RSS feed.”>
<img src=”RSS IMAGE URL” alt=”RSS” style=”position: relative; left: 0;” />
</a>
</h3>
<?php query_posts(’cat=115&showposts=2?); ?>
<?php if(have_posts()) : ?>
<?php while(have_posts()) : the_post(); ?>
<div class=”aside_post”>
<?php the_content(’Continue reading...’); ?>
</div>
<?php endwhile; ?>
<span class=”aside_archive_link”>
<a href=”CATEGORY URL” title=”More asides.”>Archives</a>
</span>
<?php else : ?><p>Sorry, the side blog is having a little trouble.</p>
<?php endif; //if you delete this the sky will fall on your head ?>

Enhancing Your “Read More” Link

  1. Open your “index.php” or file and find this line:
    <?php the_content(__(’Read more’));?>
  2. replace it with this one:
    <?php the_content(”Continue reading ” . the_title(”,”,false), 0); ?>

Enhancing Your “Comments” Link

  1. Open your index.php, archive.php, and single.php and find this line:
    <?php comments_popup_link(’Leave a Comment’, ‘1 Comment’, ‘% Comments’); ?>
  2. Replace it with this one:
    <?php comments_popup_link(__(’No comments on ‘ . the_title(”,”,false)),
    __(’One comment on ‘ . the_title(”,”,false)), __(’% comments on ‘. the_title(”,”,false))); ?>

Random Tip #1

Do NOT use the following search code in the
“search.php” file in your theme’s directory :
<?php echo $_SERVER [’PHP_SELF’]; ?>
Nobody should be allowed to search your entire server right?

Use this instead:

<?php bloginfo (’home’); ?>

Random Tip #2

Yet another bad code used in title tags or search templates:
<?php echo $s; ?>
as it allows some harmful Sql injections =(.

Use this instead:
<?php echo wp_specialchars($s, 1); ?>

Random Tip #3

Block search robots from your archive page by preventing the indexing:
<?php if(is_archive()) { ?><meta name=”robots” content=”noindex”><?php } ?>
Paste it anywhere in the “Header.php” file of your current theme’s directory in the <head> tags.

Hope this helps. Thanks for reading and have a wonderful day!

Kyle Eslick is WordPress enthusiast who took his passion for WordPress to the next level in 2007 by launching WPHacks.com as a place to share hacks, tutorials, etc. Connect with Kyle on Twitter or Google+!

  1. jbj says:

    Nice job Hayes! The “random tips” are very nice.

  2. Dave says:

    Hayes,

    Thanks for the great tips. The one on changing the “read more” was especially timely as I had just been thinking about doing that.

    I copied in your code to both my index and page templates, commented out the old code and saved both templates. The old “Read more” still displays.

    I know it’s difficult debugging code you can’t see, but any idea what I may have done wrong?

    Thanks in advance.

  3. Mehmet says:

    Thanks for the tips Hayes, I have a question though.

    Does the first tip (asides) brakes pagination function? I was trying to place asides to the sidebar of a theme I am currently updating, but so far I always had some problems. Having your answer will clear my question marks.

    Thanks again

  4. David Lau says:

    Enhancing Your “Comments” Link
    Nice!
    thanks~

  5. Hayes Potter says:

    @jbj: Thanks!

    @Dave: I have to assume that maybe your server for some reason hasn’t updated, or maybe clear your browser cache. If you have some future header expires in your .htaccess file that apply to your php files you may need to cancel them and then reset them to make it update. Thanks for the kind words!

    @Mehmet: it should not break anything, and if you feel uncomfortable with the code you can always get a wordpress plugin for the widget, or I could write you some custom php.

    @David: Thanks!

  6. Hayes Potter says:

    @jbj: Thanks!

    @Dave: I have to assume that maybe your server for some reason hasn’t updated, or maybe clear your browser cache. If you have some future header expires in your .htaccess file that apply to your php files you may need to cancel them and then reset them to make it update. Thanks for the kind words!

    @Mehmet: it should not break anything, and if you feel uncomfortable with the code you can always get a wordpress plugin for the widget, or I could write you some custom php.

    @David: Thanks!

  7. Hayes Potter says:

    @jbj: Thanks!

    @Dave: I have to assume that maybe your server for some reason hasn’t updated, or maybe clear your browser cache. If you have some future header expires in your .htaccess file that apply to your php files you may need to cancel them and then reset them to make it update. Thanks for the kind words!

    @Mehmet: it should not break anything, and if you feel uncomfortable with the code you can always get a wordpress plugin for the widget, or I could write you some custom php.

    @David: Thanks!

  8. Kyle Eslick says:

    @ Hayes – GREAT write up buddy! You have a gift at writing hacks and working with code.

  9. D&G says:

    To bas the blog of Hayes Potter is not live anymore.
    Would have loved to see his posts on his own blog.

    Dennis

  10. Hayes Potter says:

    Oh, sorry about my blog being down I don’t keep track of it that much anymore. It is live again right now, but about 6 or 7 posts I have taken off the site and contributed to other websites.

    Thanks!

  11. Hayes Potter says:

    Oh, sorry about my blog being down I don’t keep track of it that much anymore. It is live again right now, but about 6 or 7 posts I have taken off the site and contributed to other websites.

    Thanks!

  12. Hayes Potter says:

    Oh, sorry about my blog being down I don’t keep track of it that much anymore. It is live again right now, but about 6 or 7 posts I have taken off the site and contributed to other websites.

    Thanks!

  13. Jobs says:

    GReat article! Thanks for the tips! i might switch to wordpress

Trackbacks/Pingbacks »

  1. Wordpress Tips and Tricks | Theme Heven says:

Leave a Reply