6 WordPress Tips and Tricks

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:

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;” />
<?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...’); ?>
<?php endwhile; ?>
<span class=”aside_archive_link”>
<a href=”CATEGORY URL” title=”More asides.”>Archives</a>
<?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!

  • Leave a Comment