Tag Archives: Lt

bbPress: 2010-07-21 Meetup

IRC log from the meetup on July 21, 2010 [21:02:40 GMT]    <jjj>    <meetup> [21:02:58 GMT]    <jjj>    Hi [21:03:05 GMT]    =-=    Nightgunner5 is now known as jjj5 [21:03:09 GMT]    <jjj5>    Hi, jjj! [21:03:10 GMT]    <jjj>    Haha [21:03:15 GMT]    <chrishajer>    @ben jjjjj [21:03:30 GMT]    <jjj5>    [11:37:02am] <jjj3> we should do the dev chat with jjj-jjj5 [21:03:30 GMT]   [...]

Display dates as “time ago”, the easy way

To display human readable dates on your blog, you have to use the human_time_diff() function. The following piece of code will show a post date like “Posted 6 days ago”. Paste it anywhere within the loop, save the file, and you’re done. Posted <?php echo human_time_diff(get_the_time(‘U’), current_time(‘timestamp’)) . ‘ ago’; ?> Credits: PHP Snippets. Looking [...]

WordPress hack: Display post thumbnail in your RSS feed

Simply paste the following code in your functions.php file. The post thumbnail should be visible once you saved the file. function diw_post_thumbnail_feeds($content) { global $post; if(has_post_thumbnail($post->ID)) { $content = '<div>' . get_the_post_thumbnail($post->ID) . '</div>' . $content; } return $content; } add_filter('the_excerpt_rss', 'diw_post_thumbnail_feeds'); add_filter('the_content_feed', 'diw_post_thumbnail_feeds'); Thanks to Jeff Starr for this great tip! Looking for WordPress [...]

Wrapping Long URLs and Text Content with CSS

To wrap long URLs, strings of text, and other content, just apply this carefully crafted chunk of CSS code to any block-level element (e.g., perfect for <pre> tags): pre { white-space: pre; /* CSS 2.0 */ white-space: pre-wrap; /* CSS 2.1 */ white-space: pre-line; [...]

WordPress hack: Get popular posts by comments count

Simply paste the following code where you want to display your most popular posts to be displayed: $pop = $wpdb->get_results("SELECT id, post_title, comment_count FROM {$wpdb->prefix}posts WHERE post_type='post' ORDER BY comment_count DESC LIMIT 10"); <ul> foreach($pop as $post) : ?> <li> <?php echo $post->post_title; ?> </li> <?php endforeach; ?> </ul> Thanks to Neil Skoglund for this [...]

Weblog Tools Collection: Adding Scripts Properly to WordPress Part 3 – Page Detection

You might find yourself in the situation where you only want a script to run on a certain page. In fact, it’s good practice to only load your JavaScript files when absolutely necessary; loading the files on every single page is a big no-no (I’ve been chastised before for this). While on the blog’s [...]

Weblog Tools Collection: Adding Scripts Properly to WordPress Part 2 – JavaScript Localization

When adding scripts to WordPress, you will inevitably run into a small, but painful, issue of localization. Localizing a plugin or theme is relatively straightforward, but JavaScript presents its own difficulties since we can’t easily call the PHP functions necessary (which is one reason authors embed JavaScript in PHP files). Since embedding JavaScript in PHP [...]

Weblog Tools Collection: Adding Scripts Properly to WordPress Part 1 – wp_enqueue_script

Starting in WordPress 2.1 (if I remember correctly), the awesome folks at Automattic gave us the even awesomer function of wp_enqueue_script. Before that, it was every plugin or theme author for himself. If you wanted to add in a script, it was hard-coded in. As you might imagine, this presented a ton of problems. Scripts [...]

WordPress tip: Quickly secure plugin files

Paste the following in your .htaccess file. Don’t forget to backup the file before edition! <Files ~ "\.(js|css)$"> order allow,deny allow from all </Files> This recipe has been submitted by Greg Winiarski. Thanks for your contribution! Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free! [...]

WordPress tip: Insert custom content after each post

You just have to paste the following code into your functions.php and save the file. Once done, custom content will be inserted below each of your posts. function add_post_content($content) { if(!is_feed() && !is_home()) { $content .= '<p>This article is copyright &copy; '.date('Y').'&nbsp;'.bloginfo('name').'</p>'; } return $content; } add_filter('the_content', 'add_post_content'); Thanks to Jeff Starr for the great [...]

Powered by Yahoo! Answers