New book on WordPress Theme Development: WordPress Themes In Depth
tricks
Tag Archive

Delete Unwanted Context Menu Items in WinXP

Within the right-click context menu is the option to create "New" file items. While the list of available documents within the "New" submenu often contains several useful file types, such as .txt or .zip, it also contains lots of unnecessary entries. To clean up the "New" right-click context menu, open the Registry Editor, regedit.exe, and Find all instances of "ShellNew". Examine the search results. Every ShellNew branch belongs to a specific type of file. As each ShellNew branch corresponds to an entry in the "New" right-click context menu, delete the ShellNew branch for each "New" file type that you would […] Read more »

Folder Background Images in WinXP

This brief tutorial explains how to add a background image to any folder in Windows XP. First, make sure all hidden files are visible on your system. Then, open the folder for which you wish to add a background image. Within the folder, right-click and select Properties » Customize tab » Customize. There, choose any icon, click Apply and OK. That process should have created a "desktop.ini" file. Open that file with a text editor and add these lines of code: [ExtShellFolderViews] {BE098140-A513-11D0-A3A4-00C04FD706EC}={BE098140-A513-11D0-A3A4-00C04FD706EC} [{BE098140-A513-11D0-A3A4-00C04FD706EC}] IconArea_Image=C:\path\folder\background.jpg To customize this according to your needs, edit the path in the last line to […] Read more »

One Link to Open Them All

Welcome to Perishable Press! This article explains several methods for opening multiple frames with a single link. For more excellent (X)HTML information, check out the (X)HTML tag archive. If you like what you see, I encourage you to subscribe to Perishable Press for a periodic dose of online enlightenment ;) Opening Multiple Frames with One Link Method 1: The first method of targeting multiple frames involves replacing either the entire frameset (via target="_top") or a subset of frames (via target="subset"). For example, any number of frames may be updated with a single link if that link targets a new frameset containing […] Read more »

IE Scrollbar Colors

Changing the color of scrollbars for Internet Explorer may very well be the oldest trick in the book. In fact, this post exists mostly for the sake of prosperity, as we here at Perishable Press strive to eliminate our entire offline library of website design notes by transferring them to the World Wide Web. Although library conversion requires time, patience, and determination, changing the color of IE scrollbars is relatively simple. Simply associate these CSS rules to the (X)HTML documents desiring unique scrollbar colors: /* produces a stylish black scrollbar with light-grey highlights */ * html body {    scrollbar-face-color: #000; […] Read more »

Fun with Downlevel Conditional Comments

Ever since Internet Explorer 5 (IE5), Microsoft has included browser support for "downlevel conditional comments," a non-scripted method of browser detection. Downlevel conditional comments (DCC) are a useful tool for targeting directives to specific versions of Internet Explorer. Downlevel conditional comments consist of an opening statement and a closing statement. Taken together, the statements enclose markup, CSS, JavaScript, or any other element typically included within an (X)HTML document. The DCC may be placed anywhere within the document and executes its contents only for the version(s) of IE specified. This technique is useful for delivering IE-specific stylesheets exclusively to specific versions […] Read more »

Nifty CSS Link Hover Effect

This nifty CSS link hover effect magically reveals a hidden span of text after specified links. The trick employs an anonymous span nested within an anchor tag. CSS then acts upon the markup with a set of rules that basically says hide the nested span until the link is hovered. Here is an example. Here is the CSS code and XHTML markup that makes it happen: a:link, a:visited { text-decoration: underline; color: #990000; } a:hover, a:active { text-decoration: none; color: #990000; } li a:link span, li a:visited span { display: none; } li a:hover span, li a:active span { display: inline; } <ul> […] Read more »

Auto Clear and Restore Form Elements

Using a small bit of JavaScript, it is possible to auto-clear and restore form elements when users bring focus to them. Simply copy, paste, and modify the following code example to achieve an effect similar to this: Here is the HTML/JavaScript for your website: <input value=”Click here and this will disappear..” onfocus=”if(this.value == ‘Click here and this will disappear..’) {this.value = ”;}” onblur=”if (this.value == ”) {this.value = ‘Click here and this will disappear..';}” type=”text” size=”77″ /> Update [January 2nd, 2007] » Here is another auto-clear JavaScript trick that cleans up the (X)HTML code but does not auto-restore the element. […] Read more »

Display the Total Number of WordPress Posts, Comments, and Categories

Would you like to display the total number of posts, comments, and categories for your WordPress-powered website? Here is the code that can make it happen 1! Update: The count posts part of this method should only be used for WordPress versions less than 2.5. For WordPress versions 2.5 and better, there is a built-in function for displaying the total number of posts. See The WordPress Codex for more information. <?php $numposts = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = ‘publish'”); if (0 < $numposts) $numposts = number_format($numposts); $numcomms = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = ‘1’”); if (0 […] Read more »

Spamless Email Address via JavaScript

Let’s face it, spam sucks. Give spammers the figurative finger by using this nifty bit of JavaScript to hide your email address from the harvesters. Here is an easy “copy-&-paste” snippet for including a spam-proof email address in your web pages. Although there are a million ways of doing this, I am posting this for the record (and because I just can’t stand deleting usable code). This technique uses JavaScript, and therefore is not 100% ideal for all users. My advice would be to include a <noscript> element that contains an image of your email address. That way, users without […] Read more »

Crazy CSS Underline Effects

Check out these crazy CSS underline effects: u.double { /* — double underline — */ border-bottom: 1px solid; } .altdouble { /* alternate double */ border-bottom: 3px double; line-height: 1.7em; } u.triple { /* — triple threat — */ border-bottom: 3px double; line-height: 1.9em; } Double Underline Effects! (via u.double class) Alternate Double Underline! (via .altdouble class) Triple Underline Effects! (via u.triple class) Note: if these examples do not display correctly with the current theme, click here to see them in action! Read more »

CSS Hack Dumpster

Consider this page a virtual dumpster of wonderful CSS hacks.. Commented Backslash Hack V2 This hack effectively hides anything after the “\*/” from MacIE5: /* commented backslash hack v2 \*/ div#something { boder: thin solid red; } /* end hack */ May also be used for CSS import directives: <style type=”text/css”> /* commented backslash hack v2 \*/ @import url(http://www.site.com/stylesheet.css); /* end hack */ </style> Fix Division Widths in IE Fix IE’s crazy box rendering. The first line limits to only IE. The second line * html div#somediv { /* limits to all IE */ width: 300px; /* width for WinIE5.x […] Read more »

Conditionally Load WordPress Pages

Need to load a WordPress page conditionally? For example, perhaps you need a “special” page to appear for search results? Yes? This simple PHP/JavaScript solution may be just what the doctor ordered! Simply replace “condition” with the required condition (or delete the if (condition) {} qualifier entirely), and then change the path and file names to suit your specific needs: <?php if (condition) { echo (” <script type=\”text/javascript\”> <!–//–><![CDATA[//><!-- parent.location=\"http://www.domain.com/path/to/file.html\" //--><!]]> </script> “); } else { echo (” <script type=\”text/javascript\”> <!–//–><![CDATA[//><!-- parent.location=\"http://www.domain.com/path/to/other-file.html\" //--><!]]> </script> “); } ?> Specifically, I employ the following trickery in my Killer WordPress theme: <?php endwhile; […] Read more »

Execute External WordPress Functions

To execute WordPress functions in an external directory (i.e., outside of the WordPress install directory), it is necessary to include a call to “wp-blog-header.php” at the top of the external file. For example, if your WordPress-powered blog is located in a subdirectory called “blog” and the external file is in the domain root (e.g., the external file is located directly in http://domain.com/), add the following code to the top of the external file: <?php require_once(“./blog/wp-blog-header.php”); ?> This may be generalized by writing: <?php require($_SERVER['DOCUMENT_ROOT'].’/blog/wp-blog-header.php’); ?> Read more »

Stupid htaccess Tricks Redux

One of our most popular posts, Stupid htaccess Tricks, has been completely rewritten and now includes almost twice as many stupid htaccess tricks. Plus, we have added a library of regex character definitions, more information for many of the directives, and several handy references. But wait, there’s more — we even threw in a “quick-jump” Table of Contents and a complete set of “up” [ ^ ] links for easy navigation. Utterly amazing! Read more »

Associate Extensionless Files with Notepad in WinXP

There are several files that appear not to have extensions in Windows XP. Perhaps the best known example is the HOSTS file. Files such as the HOSTS file that appear to be "extensionless" actually contain an invisible period "." — or dot — at the end the file name. It is this invisible dot that will enable us to select a specific program with which to open files with no extensions. As web developers, we are constantly checking and consulting server-generated error_log files. Like the HOSTS file, the error_log files appear to have no associated extension. In Windows XP, opening […] Read more »

Backup Block Senders List in Outlook Express

Follow these steps to backup the “Block Senders” list in Outlook Express: From the Desktop, click Start then Run. In the Open box, type regedit then OK. Locate and click the following registry subkey: HKEY CURRENT USER\Identities\(Identity Number)\Software\Microsoft\Outlook Express\5.0\Block Senders Go to the Registry menu and select Export Registry File. From the Save In box, change the location to your desktop. At the File Name box, type “Blocked Senders[date].reg” then Save. Go to the Registry menu and chose exit. To restore a backup, simply right-click on the “Blocked Senders[date].reg” file that you wish to restore and select “merge.” Read more »

Latest Tweets Download the latest nightly build of WordPress: wordpress.org/nightly-builds/w…