The Design and Illustration of Peter Demaria
Wednesday, January 13th, 2010
Tomorrow morning at the bone-chilling hour of 4:00am we depart for Canada, so stoked! Friends and family, good eating and drinking await…Feel free to contact me, I won’t be completely off the grid, though it’s entirely possible I will be on top of a mountain with some good friends, eying some fresh, fluffy snow…
On return, with most of my web projects squared away, I plan on digging into some quality painting and drawing. You can expect to see some fresh T’s for Sweet Nothing Clothes, and some finished paintings as well…

Acrylic on panel, work in progress. Peter Demaria © 2010
À la prochaine!
Tags: Canada, travel
Posted in Updates | No Comments »
Monday, October 19th, 2009
Had a minor conundrum the other day involving some pretty standard WordPress type stuff.. as these things usually sometimes go, it was about 1:30 am before I actually had a working solution. Note, solutions below are not for beginners, you WILL break your theme if you don’t implement the code properly.
The problem seemed like a no-brainer at first, if you want to display a preview of a post WordPress offers two options, the_excerpt() and the_content(). If you are using the_content() you have to manually insert a ‘read more’ tag wherever you need it to appear when readers are viewing the appended version of your post. I opted for the_excerpt(), which nicely and dynamically generates a brief version of an article (or an optional, manually written excerpt), along with whatever other information you decide to include along with it in the loop.
BUT, out of the box the_excerpt() adds a nifty little blob to the end of each excerpt unless you fill in your excerpt manually, looks like this [...] Not pretty… of course there are plugins to spice up your excerpts and all that, but whenever possible I like to do a little future-proofing by writing actual code that can be baked into a theme. A little logic or some-such thing. I liked the solution I found at WP Engineer (which has conveniently disappeared, replaced by information for not-yet-released WordPress 2.9), which when added to your functions.php file, supplants WordPress’ own the_excerpt() functionality. Replace ‘better_trim_excerpt’ with your own name if your feeling feisty…
<?php
function better_trim_excerpt($text) {
global $post;
if ( '' == $text ) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
$text = strip_tags($text);
$excerpt_length = 45;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words)> $excerpt_length) {
array_pop($words);
array_push($words, '...');//'...' is what replaces the unsightly blob..
$text = implode(' ', $words);
}
}
return $text;
}
?>
Just one problem, WordPress’s wondrous auto-generated captioning was being stripped from the resulting html, but not the content of the caption (leaving hideous random text willy-nilly). Add this bit of code to our previous solution, and problem solved..
<pre>add_filter( 'img_caption_shortcode', create_function('$a, $b, $c', 'return $c;'), 10, 3 );</pre>
which gives us the following;
<?php
function better_trim_excerpt($text) {
global $post;
if ( '' == $text ) {
add_filter( 'img_caption_shortcode', create_function('$a, $b, $c', 'return $c;'), 10, 3 );
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
$text = strip_tags($text);
$excerpt_length = 45;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words)> $excerpt_length) {
array_pop($words);
array_push($words, '...');//'...' is what replaces the unsightly blob..
$text = implode(' ', $words);
}
}
return $text;
}
?>
<?php
remove_filter('get_the_excerpt', 'wp_trim_excerpt');//removes wp hook for excerpt function
add_filter('get_the_excerpt', 'better_trim_excerpt');//points wordpress to yours, name this whatever you want!
?>
Having gone through all of this, today I discovered that the_excerpt() is bound for a makeover, and with the release of 2.9 two lines of code may accomplish what took me twenty-three or so. Though I’m not positive it will solve my caption problems…
Tags: php, the excerpt, theme development, wordpress
Posted in Updates | No Comments »
Thursday, September 10th, 2009

blackbook, Peter Demaria ©2009
Busy busy busy, seems like I’m working on about ten different projects all the time. Robotic Relative is a new site from the creator of Sweet Nothing Clothes, featuring the Art and Design of Jess Hahn… And the redesign is just screaming to go live but is just not quite there yet. E-commerce is no breeze, there needs to be some advances made, I think the financial institutions need to implement some innovation and produce some kind of API.. I’m no programmer but who knows, be a lot easier if you didn’t have to write an entire back-end to exchange money for goods and services na’-mean (or hook into some greedy and inefficient middle-man service, other than your bank)..
I have about six different paintings on the go, each in a state of almost there, but not quite. And I am also designing a poster, working on the ETA site, and getting started on producing some Flash advertising… Where does it end! All this and working at Great Harvest Bread thirty hours a week, and I need you to hire me, right now!
Posted in Updates | No Comments »