Today I released a new design for stffn.dk and I desided to remove my portfolio from the site.
The new design has been underway for quite a while, and have had many different looks during that time. The design I ended up using was actually done for a completely different project — a project that never made it very far. So I made a few adjustments to the design (rewrote everything from scratch, that is…) and here it is.
The portfolio section was old and I didn’t really feel for it anymore, and most of the projects was outdated. And to be honest; I don’t do much work anymore that was fit for a portfolio.
Insted is a “experiments/playground” section in the making.
What this script does is, if a image fails to load and throws an error (caught by .error();) we simply replaces the original src-attr with a new image.
The functions.php file in every WordPress theme can contain many useful functions — everything from adding post thumbnail support to custom posttypes and your own taxonomies.
In this post I have collected a lot of functions that can help you customize your WordPress installation. Some are very useful, others are just nice workarounds of common challenges — some you might not want to use.
Remember — I’m not saying you should use ALL of the functions, or just copy/paste the whole code to your functions.php file. Only use the snippets you need as some of the code can do really bad things, depending on your setup.
Originally I came across a post over at digwp.com. They had 2 articlesdedicated to functions.php, and I desided to work from there; customize to fit my needs and adding a few of my own functions.
// enable threaded comments
function enable_threaded_comments(){
if (!is_admin()) {
if (is_singular() AND comments_open() AND (get_option('thread_comments') == 1))
wp_enqueue_script('comment-reply');
}
}
add_action('get_header', 'enable_threaded_comments');
// add google analytics to footer
function add_google_analytics() {
echo '<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>';
echo '<script type="text/javascript">';
echo 'var pageTracker = _gat._getTracker("UA-XXXXX-X");';
echo 'pageTracker._trackPageview();';
echo '</script>';
}
add_action('wp_footer', 'add_google_analytics');
// no more jumping for read more link
function no_more_jumping($post) {
return '<a href="'.get_permalink($post->ID).'" class="read-more">'.'Continue Reading'.'</a>';
}
add_filter('excerpt_more', 'no_more_jumping');
// add a favicon to your
function blog_favicon() {
echo '<link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('wpurl').'/favicon.ico" />';
}
add_action('wp_head', 'blog_favicon');
// add a favicon for your admin
function admin_favicon() {
echo '<link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('stylesheet_directory').'/images/favicon.png" />';
}
add_action('admin_head', 'admin_favicon');
// custom admin login logo
function custom_login_logo() {
echo '<style type="text/css">
h1 a { background-image: url('.get_bloginfo('template_directory').'/images/custom-login-logo.png) !important; }
</style>';
}
add_action('login_head', 'custom_login_logo');
// disable all widget areas
function disable_all_widgets($sidebars_widgets) {
//if (is_home())
$sidebars_widgets = array(false);
return $sidebars_widgets;
}
add_filter('sidebars_widgets', 'disable_all_widgets');
// kill the admin nag
if (!current_user_can('edit_users')) {
add_action('init', create_function('$a', "remove_action('init', 'wp_version_check');"), 2);
add_filter('pre_option_update_core', create_function('$a', "return null;"));
}
// category id in body and post class
function category_id_class($classes) {
global $post;
foreach((get_the_category($post-<ID)) as $category)
$classes [] = 'cat-' . $category-<cat_ID . '-id';
return $classes;
}
add_filter('post_class', 'category_id_class');
add_filter('body_class', 'category_id_class');
// get the first category id
function get_first_category_ID() {
$category = get_the_category();
return $category[0]-<cat_ID;
}