Common set of custom functions for wordpress

May 27, 2010

When designing WordPress themes, we always add a common set of custom functions to the wordpress theme’s functions.php file. This speeds up development time and optimizing many key aspects of WordPress, because we don’t have to hunt for and individually copy the same slew of functions for every theme. In this article, we deliver prime collection of custom functions to enhance your WordPress site. These new functions will help you optimize your development process while enhancing WordPress with essential functionality.... [Read the full story]

Replace wordpress Content in PRE Tags with HTML Entities

May 26, 2010

If you have a website that often display some code on your wordpress, you know the important of converting PRE tag content to their HTML entities. Doing so prevents worlds of possible rendering issues. Just paste the following in your functions.php file. Once saved, it will automatically replace all content within <pre> and </pre> tags by html entities. //replaces pre content with html entities function pre_entities($matches) { return str_replace($matches[1],htmlentities($matches[1]),$matches[0]); } //to... [Read the full story]

Automatically empty wordpress Trash

May 25, 2010

Trash is a new functionality from WordPress 2.9. When an item (post, comment, etc) is deleted, it goes in Trash instead of being permanently removed. Here is a tip to tell your WordPress blog to autmatically empty trash every X days. Simply open your wp-config.php file (located at the root of your WOrdPress install) and paste the following code: define('EMPTY_TRASH_DAYS', 10 ); The second parameter is when to empty trash, in days.  Read More →

Put HTML tags into wordpress post title

May 25, 2010

You don’t want to go putting HTML tags directly into post titles. It might show up OK on your own site, but it can be problematic. For example, your titles through RSS will show the tags as next, not render them, here is almost-as-simple way to go about it. 1. Enter title without HTML 2. Create a custom field “HTML_title” for the title with HTML 3. Output custom field on pages you want the HTML For example, on the single.php page where you would have used <h1><php the_title(); ?></h1> Now... [Read the full story]

Remove admin name in wordpress comments class

May 25, 2010

Every time we posted a comment, WordPress automatically added a class that pretty much told everyone our admin login name. The offending class is the “comment-author-admin” class. We can created a code snippet that can quickly remove the offending class from every comment. Just add follow code to your functions.php file: function remove_comment_author_class( $classes ) { foreach( $classes as $key => $class ) { if(strstr($class, "comment-author-")) { unset( $classes[$key] ); } } return $classes; } add_filter(... [Read the full story]