Tagtips

My website is now super-fast with Varnish

My website is now super-fast with Varnish — an open source HTTP accelerator which sits on top of your HTTP servers and serves your cached pages. It didn’t take me longer than 20 minutes to get Varnish up and running on my Ubuntu VPS, and a few more minutes to set all my nginx configurations to port 8080, bringing Varnish to port 80. The problem with WordPress however, is that it...

Selective Page Hierarchy for wp_list_pages

Check out Selective Page Hierarchy for wp_list_pages() where Michael Fields shows how he extended the WordPress Walker_Page class to create a selective “drilldown” page walker, which can then be used with wp_list_pages.

PayPal Default Merchant Language Settings

Note to self. If your PayPal button is directing your visitors to a non-English website (probably because your account was set up in a different country) you can override the language setting with an lc key in the PayPal button form, like this: <input type="hidden" name="lc" value="US" /> This will make sure that the checkout page is in English. Read more about HTML Variables for Website...

Git Archive for WordPress Themes

Quick tip! If you’re using Git when developing WordPress themes and would like to create a clean “export” of the theme that would be installable from the WordPress admin interface and accepted to the WordPress.org themes directory, you can use the git archive command for that with some special arguments: git archive --format zip --output /path/to/themename-1.1.zip ...

Don’t Create a Quote Shortcode

Don’t create a “quote” shortcode when the HTML “blockquote” tag does a perfectly good job. I’ve seen themes that have shortcodes for quotes, citations and headers but no support for the same styling with HTML tags.
Sawyer Hollenshead on Building WordPress Themes You Can Sell

Cleaner Titles in WordPress

Quick Tip! What happens when your post title does not fit on one line? It wraps to the second line. What if it’s only one word? And what if that word is “it” or some other shorty? Your title won’t look too nice, eh? Here’s a solution, somewhere inside the loop: $title = the_title( '<h2>', '</h2>', false ); if ( strlen( $title ) > 0 ) echo...

Post Formats in WordPress: Breaking Down Those Quotes

Here’s a function that would grab the contents HTML and parse out the first quote (blockquote element) together with it’s cite (usually the quote author) and the remaining text that comes after the quote. This is useful for when dealing with the quote post format in WordPress. function get_blockquote() { $dom = new DOMDocument; $dom->loadHTML( apply_filters( 'the_content'...

MySQL Index Hinting

Did you know that you can give a hint to MySQL on which index to use? It’s called Index Hint and can be part of a query where you feel MySQL is doing a wrong choice (although that’s quite unlikely these days.) SELECT * FROM table1 USE INDEX (your_index) WHERE col1 = 1 AND col2 = 2 AND col3 = 3; Where your_index is the name of the index you’d like to use for this query. You can...

External Links with CSS3 or jQuery

Here’s how I marked external links using CSS throughout my blog with a few simple selectors one of which is a level 3 meaning this solution will probably fail in some version of IE and other browsers with limited CSS3 support. a { background: url('') right center no-repeat; padding-right: 14px; } a[href^=""], a[href^="/"], a[href^="#"] { background: none; padding-right: inherit; } The first...

Removing YouTube and Vimeo Shortcodes in WordPress

Quick Tip! If you’ve been using WordPress for a long time you might still be locked in to using a video embed plugin like I was a few hours ago. Yes plugins are great, but these days it’s part of the WordPress core. So how do you get rid of those YouTube and Vimeo shortcodes? I haven’t found an easy way to do it and yes I’m still frustrated with the shortcodes concept in...