automatic_feed_links(); // Enable to choose a file as a thumbnail from the post/media editor view since WP2.9 add_theme_support( 'post-thumbnails' ); // Comments_Template include (TEMPLATEPATH . '/comments-list.php'); /* Sidebars * * * * * * * * * * * */ if ( function_exists('register_sidebar') ) { register_sidebar(array( 'id' => 'sidebar_right', 'name' => 'On the Right', 'description' => 'To style this sidebar use this class: .blog_sidebar_right', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'id' => 'sidebar_right_subsidiary', 'name' => 'Subsidiary on the Right', 'description' => 'To style this sidebar use this class: .blog_sidebar_right_subsidiary', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'id' => 'sidebar_left', 'name' => 'On the Left', 'description' => 'To style this sidebar use this class: .blog_sidebar_left', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'id' => 'sidebar_left_subsidiary', 'name' => 'Subsidiary on the Left', 'description' => 'To style this sidebar use this class: .blog_sidebar_left_subsidiary', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'id' => 'sidebar_in_header', 'name' => 'In the Header', 'description' => 'To style this sidebar use this class: .site_sidebar_top', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'id' => 'sidebar_in_footer', 'name' => 'In the Footer', 'description' => 'To style this sidebar use this class: .site_sidebar_bottom', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'id' => 'sidebar_before_posts', 'name' => 'Before the Posts', 'description' => 'To style this sidebar use this class: .posts_sidebar_top', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'id' => 'sidebar_after_posts', 'name' => 'After the Posts', 'description' => 'To style this sidebar use this class: .posts_sidebar_bottom', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); } /* Custom functions * * * * * * * * * * * */ // Get the id of a page by its name(slug) function get_page_id($page_name){ global $wpdb; $page_name = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '".$page_name."'"); return $page_name; } // Check if the page is a child page function is_subpage() { global $post; if ( is_page() && $post->post_parent ) { $parentID = $post->post_parent; return $parentID; } else { return false; }; } // Check if the post has an image function has_post_image() { global $post; $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID, 'post_mime_type'=> 'image' ); $attachments = get_posts($args); return !empty($attachments); } // Return an tag with the first image of the post function the_post_image( $size ) { global $post; $attachments = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'numberposts' => 1, // show all -1 'post_status' => 'inherit', 'post_mime_type'=> 'image', 'order' => 'ASC', 'orderby' => 'menu_order ASC' ) ); foreach ( $attachments as $attachment_id => $attachment ) { $images .= wp_get_attachment_image( $attachment_id, $size ); }; echo $images; } // Get the template that WordPress is using function get_hierarchy(){ if ( is_day() ){ echo the_date(); } elseif ( is_month() ){ echo get_the_time('F Y'); } elseif ( is_year() ){ echo get_the_time('Y'); } elseif ( is_tag() ){ echo single_tag_title('', false); } elseif ( is_category() ){ echo single_cat_title('', false); } elseif ( is_archive() ){ echo 'Blog Archives'; } elseif ( is_author() ){ echo 'Author Archive'; } elseif ( is_attachment()){ echo 'Attachment'; } elseif ( is_subpage() ){ echo 'Sub Page'; } elseif ( is_page() ){ echo 'Page'; } elseif ( is_single() ){ echo 'Single'; } elseif ( is_home() ){ echo 'Home'; } elseif ( is_front_page()){ echo 'Home'; } }; ?>