基于自带主题twentyten修改

                   第一次接触wordpress   还不是很懂  写下笔记


加链接:直接http://www.xxxxxx.com/xxx/?cat=30即可  //分类

       或者http://www.xxxxxx.com/xxx?p=30即可     //文章

图片路径:<img src="<?php bloginfo('template_url'); ?>/p_w_picpaths/vk.jpg"/>


输出分类列表框(里面包含8篇文章):      

<?php

      // 得到所有分类列表

     $categories = get_categories();


     // 循环所有分类

     foreach ($categories as $cat) {


     // 得到分类ID

      $catid = $cat->cat_ID;


     // 得到分类下8篇最新文章

     query_posts("showposts=8&cat=$catid"); ?>


     <div id="text">

       <div class="title">

         &nbsp;<img src="<?php bloginfo('template_url'); ?>/p_w_picpaths/texttitle_tag.jpg"/>&nbsp

         <!– 输出分类标题及链接 –>

         <a href="<?php echo get_category_link($catid);?>"

           title="<?php echo strip_tags(category_description($catid)); ?>">

           <?php single_cat_title(); ?>

         </a>

       </div>

       <div class="content">

         <!– 输出8篇最新文章的标题及链接 –>

         <ul>

         <?php while (have_posts()) : the_post(); ?>

           <li>

             <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">

 <?php the_title(); ?></a>

 <p><?php the_time('m-d'); ?></p>

           </li>

           <?php endwhile; ?>

         </ul>

       </div>

     </div>

<?php } ?>



输出分类标题列表:

<div class="kate_list">

<ul>

<?php wp_list_categories('title_li=&current_category='.$id);?>

</ul>

</div>




引入头部等文件:<?php get_header(); ?>

<?php get_sidebar(); ?>

<?php get_footer(); ?>


*****************category**********************///

显示分类的类名:<?php single_cat_title();?>


<?php get_template_part( $slug, $name ) ?>

$slug (必须) 通用的模板名

$name (可选) 指定的模板名

例如:<?php get_template_part( 'loop', 'category' ); ?>


显示评论:<?php comments_template( '', true ); ?>   在loop-single.php里






FAQ的文件组成:

index.php//主入口文件

       style.css//主样式文件

category.php//分类目录

loop.php//分类文章目录(被category调用)

single.php//详细页面

loop-single.php//详细页面具体显示(被single.php调用)

page.php//单页

loop-page.php//单页(被page.php调用)

comments.php//评论模块

function.php//自定义函数在里面,以修改主题功能


The Loop:

它是“循环的查询结果”。循环体中我们可以依次输出选中文章的标题,博客内容,元数据,评论等。我们还可以在single page中使用多个loop。例如,我们可以用一个loop显示博客全文,另一个loop显示相关文章的标题和缩略图。

The Loop结构如下:

Query post or page  

Start Loop //循环开始  

the_title (outputs the title of the post) //标题  

the_excerpt (outputs the post excerpt) //摘要  

the_content (outputs the full post content) //内容  

the_category (outputs the post categories) //目录  

the_author (outputs the post author) //作者  

the_date (outputs the post date) //日期  

other tags (there is a variety of other tags you can use in the loop) //标签  

endwhile; //结束循环  

Exit the loop //退出循环


自制searchform.php://******这里显示的就是你那个搜索框的样子*****//

<form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">

<div class="suche">

<input type="text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" size="15" />

<input type="submit" id="searchsubmit" value="Suche" />

</div>

</form>


搜索的循环体在search.php里面