Display wordpress posts in columns
April 15, 2009
For those of you who want a simple but limited approach (not using a plug-in), here’s the code for your theme for multiple columns within a page. It is set up to use 3 columns but is easy to modify to N columns. To split your post content in columns, the first thing to do is to format your posts that way: potential content goes here that appears before the columns. [–column–] Content for column 1 here. [–column–] Content for column 2 here. [–column–] Content for column 3 here Once... [Read the full story]
Get latest sticky posts of wordpress
April 11, 2009
Stciky posts are an awesome new functionality of wordpress, but sadly, retrieving and sorting them isn’t easy as you can expect. We’ll assume you already have The Loop set up in one of your template files (i.e., home.php, custom-page.php). What we need to do is call up a specific number of stickies. For this example, we’ll load the five latest sticky posts. Place the following code just before the loop: <?php $sticky = get_option('sticky_posts'); rsort( $sticky ); $sticky = array_slice( $sticky, 0, 5); ... [Read the full story]
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]