wordpress二次开发随笔

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

相关文章
相关标签/搜索