New WP theme released for iPhone and Android designed with touch-screen phones in mind:
bravenewcode.com/wptouch
Update: Just installed this theme on underblob. It is actually installed as a plug-in and not as a theme, which makes a lot more sense. The plug-in auto-detects user agent string and spits out the wptouch theme if you are viewing on a mobile device. This way it preserves your existing theme for peeps coming in on their desktop browsers. Pretty clever!
Comments Off
I make a form in a Custom Template in my WordPress Theme. I submit the form to a PHP script in the theme directory via bloginfo ( ‘template_directory’ ). I want to be able to generate an email and have it sent to the admin email address that’s set in the WP installation. How can I access the Template Tags in the stand-alone submission script? By pure dumb luck I found the right two lines of code to paste into my script:
require_once ( $_SERVER[ 'DOCUMENT_ROOT' ] . '/wp-load.php' );
wp ();
Now I created a reusable script that I can drop into any WordPress Theme by inserting the Site Name via get_bloginfo ( ‘name’ ) into the subject and sending the email to the Site Admin via get_bloginfo ( ‘admin_email’ ).
Links
WordPress.org/Template_Tags
PHP.net/mail-function
Comments Off
Here is how to get WordPress Post categories via straight SQL query:
SELECT
wp_term_taxonomy.description,
wp_terms.term_id,
wp_terms.name,
wp_terms.slug
FROM wp_term_taxonomy
JOIN wp_terms ON ( wp_term_taxonomy.term_id = wp_terms.term_id )
WHERE wp_term_taxonomy.taxonomy = 'category'
Comments Off
In WordPress, there isn’t a simple template tag to get the category slug or description if you’re making a category.php template. Here is a little work-around:
$cat = get_query_var ( 'cat' );
$catslug = get_category ( $cat )->slug;
$catdesc = get_category ( $cat )->description;
Comments Off
Separating the images from content using strip_tags in a WordPress Template to control the page layout. Using the CryptX plugin to encrypt mailto and email addresses so they won’t get picked up by spam bots. After installing the plugin, you can call the cryptx function directly from the Template to apply the encryption:
if ( function_exists ( 'cryptx' ) ) :
cryptx ( $content, $text, $css, $echo );
endif;
$content is the string to encrypt.
$text is the string to replace the text inside the alt attribute of the <a> or <img> tags.
$css is the css class to assign to the link.
$echo is set to false to return the result in a variable, true to echo the result to the browser.
Links
CryptX plugin page: wordpress.org/cryptx
CryptX author’s site: weber-nrw.de
PHP function to strip HTML and PHP tags: php.net/strip-tags
Comments Off
Problem: want to create a WP Template that uses a different CSS file from the Theme CSS so that the HTML structure remains the same but the Template layout will be different, dictated by the CSS. It works to put a <link> to the CSS in the Template HTML but then it gets rendered in <body> instead of the <head>, which is a little wonky. How to get the CSS into the <head>?
Solution: Insert this PHP code into the beginning of your Template file before the get_header() call…
<?php
function mytemplate_head () {
echo ‘<link rel=”stylesheet” type=”text/css” href=”‘ . get_bloginfo(‘template_directory’) . ‘/mytemplate.css” />’;
}
add_action ( ‘wp_head’, ‘mytemplate_head’ );
?>
Links
get_bloginfo
add_action
get_header
Comments Off
$sql = "
SELECT $wpdb->posts.*
FROM $wpdb->posts
WHERE $wpdb->posts.ID = ‘$page_id’
";
$posts = $wpdb->get_results ( $sql, OBJECT );
if ( $posts ) {
foreach ( $posts as $post ) {
setup_postdata ( $post );
if ( $post->ID == $page_id ) break;
}
}
Links
bnee.com/list-pages-in-wordpress-into-a-php-array/
Comments Off
Smashing Magazine announced today the release of an image-driven WordPress theme:
smashingmagazine.com/download-gallery-a-free-wordpress-theme

Comments Off
Trying to figure out how to put comments in a post in “the Loop”, found this article on flisterz.com. Unfortunately there isn’t a built in template tag in the WordPress API that will easily work so it takes some PHP trickery. Check it out:
http://www.flisterz.com/2008/08/09/wordpress-show-latest-comments-for-each-post-on-main-page/
Comments Off
Impact sent us a link to this article about some useful WordPress hacks:
http://www.smashingmagazine.com/2009/04/15/10-exceptional-wordpress-hacks/
The ninth entry, “Highlight Searched Text In Search Results” is a tiny code snippet god-send if you are regular expression illiterate like us:
<?php
$content = nl2br ( strip_tags ( get_the_content ( __( 'more…' ) ) ) );
$keys = explode ( " ", $s );
$content = preg_replace ( "/(" . implode ( "|", $keys ) . ")/iu",
'<strong class="search-excerpt">\0</strong>',
$content);
?>
Works like a champ!
There is also another helpful trick in this article. Up at number four, “Create A Maintenance Page For Your WordPress Blog”. This one is an .htaccess modification to keep visitors from seeing your site while you are making updates…
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123
RewriteRule $ /maintenance.html [R=302,L]
Replace the IP Address with yours and you’ll be able to see your pages but everyone else will get redirected to the maintenance.html page. Brilliant!
Comments Off