Introducing WpRecipes

Since I launched my blog Cats Who Code, I received many emails from my readers, mostly asking WordPress related questions. Due to the fact that a private reply will never help someone else, I came across the idea of creating a WordPress related blog, focused of short, precise and concise recipes.

So, I’m very happy to introduce you WpRecipes. On this new blog, you’ll not find any long and detailed tutorials like the ones I write for WordPress Hacks, but only short and “straight to the essential” recipes.

WordPress recipes

For example, I’ll show you how to redirect WordPress rss feeds to Feedburner with .htaccess, how to restrict page view to authenticated users only or how to get rid of curly quotes on your WordPress blog.

Don’t hesitate to subscribe to WpRecipes rss feed or save the blog to Delicious! And if you have any WordPress related questions, feel free to ask and I’ll se what I can do to help you.

Tweet This | Digg This | Stumble it |

6 WordPress Tips and Tricks

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!

Tweet This | Digg This | Stumble it |