Insert ads on your wordpress RSS feed
November 13, 2008
Did you ever wonder how some people are able to display ads on their rss feed? Sure, you can modify core files to do it, but that’s not a good idea at all. Here’s a clean way to insert ads (or anything) on your rss feed, without having to hack any core file. Here, we first create a function called insertAds(), which concatenate a code containing our advertisment to the $content variable, which contains the content of the post. Then, we use the add_filter() function to overwrite the the_content_rss() function with our... [Read the full story]
Get wordpress posts published exactly one year ago
November 12, 2008
Here’s a nice idea to give a second life to your old posts: This code display automatically the posts you published exactly one year ago. simply paste the following code where you want posts published exactly one year ago to appear. <?php $current_day = date('j'); $last_year = date(‘Y’)-1; query_posts('day='.$current_day.'&year='.$last_year); if (have_posts()): while (have_posts()) : the_post(); the_title(); the_excerpt(); endwhile; endif; ?> Read More →
List wordpress scheduled posts
November 11, 2008
Here’s a good idea to make your readers visit your blog more often, or suscribe to your rss feed: What about listing the title of your scheduled posts? Just paste the following code anywhere on your template where you want your scheduled posts to be listed. You can change the max number or displayed posts by changing the value of showposts in the query. <?php $my_query = new WP_Query('post_status=future&order=DESC&showposts=5'); if ($my_query->have_posts()) { while ($my_query->have_posts()) : $my_query->the_post(); ... [Read the full story]
Make your comments template compatible with WordPress 2.7 and older versions
November 11, 2008
You’ll need two file: The first one is a WordPress 2.7 compatible comments file, named comments.php. The second one is a comment template for older WordPress versions, named legacy.comments.php in this exemple. Paste this elegant code in your theme functions.php file. Create this file if it do not exists yet. If the wp_list_comments() function doesn’t exists, the code will automatically load legacy.comments.php instead of comments.php. <?php add_filter('comments_template', 'legacy_comments'); function legacy_comments($file)... [Read the full story]
Only display private posts to logged wordpress users in the loop
November 11, 2008
If you want to be able to display private posts only to registered users within the loop, I’m explaining how to do it, with a code exemple you can re-use on your blog. you’ll have to define a custom field named private, with true as a value, to each private post will have. In our WordPress loop, we’ll check if the post have a private custom field, and if true is its value. If yes, we’ll check out if the user is logged in. If he is, the post will be displayed. Otherwise, it will not. Replace your current WordPress... [Read the full story]




















