1 調用分類 2 3 <?php 4 $categories = get_categories(); 5 foreach($categories as $category): 6 ?> 7 8 <li><a href="?cat=<?php echo $category->cat_ID; ?>" class="selected filter-data"> 9 <?php echo $category->name; ?></a></li> 10 11 <?php endforeach; ?>javascript
首頁和欄目頁摘要調用 <?php the_excerpt();?> 文章頁摘要(其實主要是在single.php可使用) <?php global $more ; $more = false; ?> <?php the_content('(more)');?> <?php $more = true; ?>php
調用具體欄目的文章摘要 <?php $posts = get_posts( "category=6&numberposts=1" ); ?> <?php if( $posts ) : ?> <?php foreach( $posts as $post ) : setup_postdata( $post ); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><h2><?php the_title(); ?></h2> </a> <p class="ttime"><?php the_time('Y年M月d日g:i a'); ?></p> <p><?php the_content(); ?></p> <?php endforeach; ?> <?php endif; ?>html
調用分類文章【自動判斷欄目】 <?php if( $posts ) : ?> <?php foreach( $posts as $post ) : setup_postdata( $post ); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><h2><?php the_title(); ?></h2> </a> <p class="ttime"><?php the_time('r'); ?></p> <p><?php the_content(); ?></p> <?php endforeach; ?> <?php endif; ?>java
調用文章中第一個圖片,此代碼應該寫在function.php中 function 那個echo_first_image($width="85",$height="100") { global $post, $posts; ob_start(); ob_end_clean(); //經過正則表達式匹配文章內容中的圖片標籤 $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); //第一張圖片的html代碼,下面加了那個縮放的js哦。。若是你不打算縮放,請刪除 $first_img = '<img src="'. $matches[1][0] .'" width="'.$width.'" height="'.$width.'" alt="'.$post->post_title .'" onload="javascript:DrawImage(this,'.$width.','.$height.')" />'; if(empty($matches[1][0])){ //若是文章中沒有圖片,就調用下面的的默認代碼,本身改圖片url,也有縮放js $first_img = '<img src="'. get_bloginfo('template_url') .'/images/defalt.jpg" alt="'.$post->post_title .'" width="'.$width.'" height="'.$height.'" class="img-sidebar"/>'; } //輸出代碼 echo '<a href="'.get_permalink().'" title="'.$post->post_title.'" >'. $first_img .'</a>'; } 頁面中調用應該這樣寫 <?php echo_first_image('85','100');?>正則表達式
wp_options wp的整體信息表ide
用戶相關post
wp_userthis
wp_usermetaurl
分類相關htm
wp_term 菜單分類表
wp_term_relationship 分類關係表
wp_term_taxonomy 分類表的分類表
wp_links 友情連接表
wp_links的分類表和菜單欄目的分類表是同樣的都是wp_term_taxonomy
分類的依據是taxonomy列的名稱,值是link_category是友情連接的分類名
值是category是菜單分類名。還有一個count列,記錄了相關分類下的文章和子連接
wp_links的分類表和菜單欄目的分類表是同樣的都是wp_term_taxonomy
分類的依據是taxonomy列的名稱,值是link_category是友情連接的分類名
值是category是菜單分類名。還有一個count列,記錄了相關分類下的文章和子連接
文章相關表
wp_postmeta
wp_posts
評論相關
wp_comments
wp_commentsmeta