|
显示favicon图标- <link rel="shortcut icon" type="image/ico" href="<?php bloginfo('stylesheet_directory'); ?>/images/favicon.ico" />
复制代码 无插件调用最新文章的例表(20代表要调用的文章数)- <?php wp_get_archives('type=postbypost&limit=20'); ?>
复制代码 最新评论的调用,把下面语句加入到functions.php文件的 ? > 之前- function get_new_comment_list() {
- global $wpdb;
- $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,30) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 10";
- $comments = $wpdb->get_results($sql);
- $output = $pre_HTML;
- $output .= "\n<ul class="sidelist">";
- foreach ($comments as $comment) {
- $output .= "\n<li>". "<a href="" . get_permalink($comment->ID) . "#comment-" . $comment->comment_ID . "" title="发表于《".
- $comment->post_title . "》">" . strip_tags($comment->com_excerpt) ."</a></li>";}
- $output .= "\n</ul>";
- $output .= $post_HTML;
- echo $output;
- }
复制代码 调用方法:在所要显示的地方加上如下代码。- <?php get_new_comment_list(); ?>
复制代码 显示指定分类的描述(1代表分类ID为1)- <?php echo category_description(1); ?>
复制代码 按分类显示每个分类的最新文章,代码如下:(其中的1,3,4,5,6,7是你要显示的分类ID号)- <?php $display_categories = array(1,3,4,5,6,7); foreach ($display_categories as $category) { ?>
- <div class="postlist">
- <?php query_posts("showposts=5&cat=$category"); $wp_query->is_category = false; $wp_query->is_archive = false; $wp_query->is_home = true; ?>
- <h3 class="posttitle"><span class="more"><a href="<?php echo get_category_link($category);?>">» 查看更多</a></span><?php single_cat_title(); ?></h3>
- <ul>
- <?php if (have_posts()) : ?>
- <?php while (have_posts()) : the_post(); ?>
- <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
- <?php endwhile; ?>
- <?php else : ?><p class="center">此分类暂无内容</p>
- <?php endif; ?>
- </ul>
- </div>
- <?php } ?>
复制代码 |
|