'Sidebar', 'before_widget' => '
', 'after_widget' => '


', 'before_title' => '

', 'after_title' => '

', )); // post_thumbnail function post_thumbnail( $width = 100,$height = 80 ){ //略缩图默认大小 global $post; if( has_post_thumbnail() ){ $timthumb_src =wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'full'); $post_timthumb = ''.$post->post_title.''; echo $post_timthumb; } else { $post_timthumb = ''; ob_start(); ob_end_clean(); $output = preg_match('//i',$post->post_content, $index_matches); $first_img_src = $index_matches [1]; if( !empty($first_img_src) ){ $path_parts = pathinfo($first_img_src); $first_img_name = $path_parts["basename"]; $first_img_pic = get_bloginfo('wpurl').'/cache/'.$first_img_name; $first_img_file = ABSPATH. 'cache/'.$first_img_name; //保存地址 $expired = 604800; //略缩图过期时间 if ( !is_file($first_img_file) || (time() -filemtime($first_img_file)) > $expired ){ copy($first_img_src, $first_img_file); $post_timthumb = ''.$post->post_title.''; } $post_timthumb = ''.$post->post_title.''; } else { $post_timthumb = ''.$post->post_title.''; //如果日志中没有图片,则显示默认,自行制作默认图片 } echo $post_timthumb; } } /* pagenavi */ function pagenavi( $p = 2 ) { if ( is_singular() ) return; global $wp_query, $paged; $max_page = $wp_query->max_num_pages; if ( $max_page == 1 ) return; if ( empty( $paged ) ) $paged = 1; echo '第 ' . $paged . ' 页 , 共 ' . $max_page . ' 页 '; if ( $paged > $p + 1 ) p_link( 1, '最前页' ); if ( $paged > $p + 2 ) echo '...'; for( $i = $paged - $p; $i <= $paged + $p; $i++ ) { if ( $i > 0 && $i <= $max_page ) $i == $paged ? print "{$i} " : p_link( $i ); } if ( $paged < $max_page - $p - 1 ) echo '...'; if ( $paged < $max_page - $p ) p_link( $max_page, '最末页' ); } function p_link( $i, $title = '' ) { if ( $title == '' ) $title = "第 {$i} 页"; echo "{$i} "; } /* Displays the top 10 commentators */ function dp_top_commentators($limit=10) { global $wpdb; $sql = "SELECT $wpdb->comments.comment_author, $wpdb->comments.comment_author_email, $wpdb->comments.comment_author_url, COUNT( $wpdb->comments.comment_ID ) AS comment_count FROM $wpdb->comments WHERE MONTH(comment_date)=MONTH(now()) and YEAR(comment_date)=YEAR(now()) AND comment_author != 'Jeff' AND $wpdb->comments.comment_approved=1 Group BY $wpdb->comments.comment_author_email ORDER BY comment_count LIMIT $limit"; $topcommentators = $wpdb->get_results($sql, OBJECT); foreach ($topcommentators as $tc) { ?> comment_author; ?> / */ function childtheme_post_header(){ if ( (time()-get_the_time('U')) <= (2*86400) ) { echo '
NEW!
'; } } /* Displays post image attachment (sizes: thumbnail, medium, full) */ function dp_attachment_image($postid=0, $size='thumbnail', $attributes='') { if ($postid<1) $postid = get_the_ID(); if ($images = get_children(array( 'post_parent' => $postid, 'post_type' => 'attachment', 'numberposts' => 1, 'post_mime_type' => 'image',))) foreach($images as $image) { $attachment=wp_get_attachment_image_src($image->ID, $size); ?> class="glide-image-small"/>