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 →

Page 2 of 2«12