Automatically insert content after each wordpress post

April 7, 2009

Most wordpress blogs automatically displays some text after each post, for exemple to ask readers to subscribe to their rss feed of the blog. This text is very often hardcoded. Fortunately, we can using function.php instead, and be able to manage all in one place when  you’ll switch theme. Simply paste the following code in your functions.php file. By using functions.php, you’ll not have to re-insert this code if you switch themes. function insertFootNote($content) { if(!is_feed() && !is_home()) { $content.=... [Read the full story]

Prevent post images from being displayed on homepage

April 4, 2009

When using images in your posts, you not always want them to be shown on your blog homepage. How to prevent any images from the post to be displayed on the homepage? It is easy, Simply paste this code in your functions.php file: <?php add_filter('the_content','wpi_image_content_filter',11); function wpi_image_content_filter($content){     if (is_home() || is_front_page()){       $content = preg_replace("/<img[^>]+\>/i", "", $content);     }     return $content; } ?>  Read More →

Create Google-Style Page Navigation for wordpress

March 26, 2009

It can be very tedious to navigate through a category on a WordPress blog. Your navigation options tend to be limited to “Next Page”/”Previous Page”. Not the most efficient method in the world… When you do a search on Google, you can skip to page 3, 4, 5 or anything else. And once you do, you can always click back to page 1. It makes flicking through a large number of results much, much easier. So, why don’t we recreate that in WordPress by ourself? This bit is easy. Just copy and paste the following... [Read the full story]

Display most popular content in wordpress sidebar

March 26, 2009

Highlighting the most popular posts on your site is a great way to send new visitors to your very best content and win them over. What about giving them a quick access to your most commented posts? There are a few different ways you can do this, and quite a few plugins out there to help. What we’re going to do is quite simple, we will set up a query to get an ordered list of your most commented posts from your database, and then display those any way we like. Setting this up as a sidebar widget is very easy. Just copy... [Read the full story]

Exclude Certain WordPress Categories from Being Searched

March 18, 2009

You may not want all of your categories to appear in your search results. For example, if you’ve set up a sidebar asides category, you may not want those short snippets tangling up with your results. To remove a category, first open up your theme’s functions.php file (Or create a blank file with that name if your theme doesn’t have one); Then paste the following code at the end: <?php function SearchFilter($query) { if ($query->is_search) { $query->set('cat','8,16'); } return $query; } add_filter('pre_get_posts','SearchFilter'); ?> Simply... [Read the full story]