New book on WordPress Theme Development: WordPress Themes In Depth
2006 Aug
Monthly Archive

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 »

XHTML Document Header Resource

This XHTML header tags resource is a work in progress, perpetually expanding and evolving as new information is obtained, explored, and integrated. Hopefully, you will find it useful in some way. Even better, perhaps you will share any complimentary or critical information concerning the contents of this article. Table of Contents Important Information XML Declaration The !DOCTYPE The html tag The head tag The title tag base & item http-equiv link tags meta tags Geo meta tags Dublin Core tags References 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 »

Optimize Convoluted Code via JavaScript

Search engines loathe crawling through convoluted lines of code. Oceans of complex JavaScript scare away the priceless indexing and archiving efforts of most major search engines, which will generally abort a crawl upon encountering such mess. The good news is that search engines actually do not deploy JavaScript, so it is possible to use JavaScript to hide those miles of messy code by using the fundamental document.write function. Place this function in an external JavaScript file, “navmenu.js”: function navMenu() { document.open(); document.write(“<div>Convoluted code goes here.</div>”); document.close(); } Link to the external JavaScript file by placing this code in the document […] Read more »

HTML Frames Notes Plus

If you think that nobody uses frames anymore, think again. I personally know of one person who threw down some tuf HTML frame action for a personal site. So, in the interest of prosperity, we are hereby establishing this post as our official dumping ground for all HTML frame-related garbage. Break your pages out of someone else’s frames We begin our journey with a totally sick JavaScript method for breaking pages out of the illegitimate frames of some ineffectually pathetic bastard: <script type=”text/javascript”> <!–//–><![CDATA[//><!-- if (window.self ! = window.top) window.top.location = window.self.location; //--><!]]> </script> Likewise, here is an equally effective […] Read more »

BlogStats PCC Plugin

Update (2012/11/08): BlogStats PCC has been rebuilt with all new features and options. Check out Simple Blog Stats for all the action! </update> Announcing the BlogStats PCC plugin for WordPress! BlogStats PCC is the easy way to display the total number of posts, comments, categories, as well as several other great statistics for your WordPress-powered website. With BlogStats PCC, you display only the information you want, where you want — inside or outside of the WordPress loop. Completely customizable, BlogStats PCC will display any combination of statistics you choose. This plugin is highly flexible, simple to use, and completely free. […] 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 »

Accessibility Notes Plus

Just a few useful accessibility notes.. Add accesskey attributes to important list items, content areas, and any other key areas of the document. Use alphanumeric characters as accesskey values, as in this example: <ul> <li><a id=”home” accesskey=”h” href=”http://domain.com/home.html”><span class=”accesskey”>h</span>home</a></li> <li><a id=”menu” accesskey=”m” href=”http://domain.com/menu.html”><span class=”accesskey”>m</span>menu</a></li> <li><a id=”search” accesskey=”s” href=”http://domain.com/search.html”><span class=”accesskey”>s</span>search</a></li> </ul> When an accesskey attribute is present within a link tag, pressing alt+letter on the keyboard is equivalent to double-clicking that link. Generally speaking, the presence of an accesskey attribute within an element brings focus to that element. Thus, radio and check boxes are toggled, links are clicked, and form elements […] 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 »

Press Color Archive

Our official location for dumping notable color swatches: | #1A1A1A | #383838 | #666677 | #E1E1E1 | #F0F0F0 | #F2F2F2 | #F3F3F3 | #FFFFEE | #CCDDAA Read more »

sIFR Notes Plus

Here are a few sIFR Notes for Perishable Press. Just what are we looking at here? Well, first it is important to understand the sIFR variables and the order in which they should appear: (sSelector, sFlashSrc, sColor, sLinkColor, sHoverColor, sBgColor, nPaddingTop, nPaddingRight, nPaddingBottom, nPaddingLeft, sFlashVars, sCase, sWmode) The variable, sFlashVars consists of the following sub-variables (these should be seperated with an & sign: # Align Flash text block textalign=center # Moves text any number of pixels to the right offsetLeft=3 # Moves text any number of pixels down offsetTop=3 # Adds underline links when hovered underline=true Then, inducing from the […] Read more »

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