WordPress默认数据库表
wordpress在没有插件的情况下,默认有11个表,注意不要删除!!
wp_commentmeta:存储评论的元数据
wp_comments:存储评论
wp_links:存储友情链接(Girl is coding)
wp_options:存储WordPress系统选项和插件、主题配置
wp_postmeta:存储文章(包括页面、上传文件、修订)的元数据
wp_posts:存储文章(包括页面、上传文件、修订)
wp_terms:存储每个目录、标签、分类
wp_term_relationships:存储每个文章、链接和对应分类的关系
wp_term_taxonomy:存储每个目录、标签所对应的分类
wp_usermeta:存储用户的元数据
wp_users:存储用户
主题结构文件
style.css : CSS(样式表)文件
index.php : 主页模板
archive.php : Archive/Category模板
404.php : Not Found 错误页模板
comments.php : 留言/回复模板
footer.php : Footer模板
header.php : Header模板
sidebar.php : 侧栏模板
page.php : 内容页(Page)模板
single.php : 内容页(Post)模板
searchform.php : 搜索表单模板
search.php : 搜索结果模板
当然,具体到特定的某款模板,可能不止这些文件,但一般而言,这些文件是每套模板所必备的。
判断页面函数
is_admin() :判断是否为后台管理控制面板.
is_home() : 是否为主页
is_single() : 是否为内容页(Post)
is_single(’17′) :判断是否为ID17的单篇日志.
is_single(array(17, 19, 1, 11)) 判断是否为ID 17, 19, 1, 11 的文章
is_page() : 是否为内容页(Page)
is_page(’42′) 判断是否ID 42的页面.
is_sticky() :判断是否为置顶文章
is_sticky(’17′) 判断是否为ID17的置顶文章.
is_category() : 是否为Category/Archive页
in_category( array( 1,2,3 ) ) 判断当前文章的分类ID是否为 1, 2, 或 3
is_tag() : 是否为Tag存档页
is_date() : 是否为指定日期存档页
is_year() : 是否为指定年份存档页
is_month() : 是否为指定月份存档页
is_day() : 是否为指定日存档页
is_time() : 是否为指定时间存档页
is_archive() : 是否为存档页
is_search() : 是否为搜索结果页
is_404() : 是否为 “HTTP 404: Not Found” 错误页
is_paged() : 主页/Category/Archive页是否以多页显示
is_mobile()移动判断
is_attachment() 判断是否为附件文档
head常用
<!-- 站点标题 -->
wp_title('-',true,'right');
<!-- 项目绝对路径 -->
get_template_directory_uri();
<!-- 初始且可以添加删除相关js/css源文件 -->
wp_head();
<!-- 获取网站feed路径 -->
bloginfo('rss2_url');
<!-- 获取网站副标题 -->
bloginfo('description');
<!-- 获取网站主页路径 -->
bloginfo('url');
<!-- 获取搜索框,可以重写seachfrom.php文件 -->
get_search_form();
index常用
<!-- ------------【index常用】------------ -->
<!-- 引用head文件 -->
get_header();
<!-- 引用foot文件 -->
get_footer();
<!-- 文章主循环 -->
<?php if( have_posts() ) : while( have_posts() ) : the_post(); ?>
<!-- 渲染数据 -->
<?php endwhile; ?>
<?php endif; ?>
<!-- 显示当前文章标题 -->
the_title();
<!-- 显示当前文章路径 -->
the_permalink();
<!-- 是否有缩略图,此功能需要functions开启 -->
has_post_thumbnail();
<!-- 显示当前文章的缩略图 -->
the_post_thumbnail();
<!-- 获取当前文章内容,只是获取了返回值,如需显示需要在函数前面添加echo -->
get_the_content();
<!-- 获取当前文章浏览次数,实际方法为get_post_meta,此方法为重写方法 -->
getPostViews( get_the_ID() );
<!-- 获取当前文章分类 -->
the_category(',');
<!-- 获取当前文章发布的时间 -->
the_time('Y年m月d日 H:i:s');
<!-- 编辑文章 -->
edit_post_link('编辑');
<!-- 判断当前文章是否有标签 -->
has_tag();
<!-- 显示当前文章所有的标签 -->
the_tags('',',','');
<!-- 显示文章的评论条数 -->
comments_popup_link('0','1','%');
<!-- 分页函数,自定义 -->
lingfeng_pagenavi();
<!-- 导航菜单函数,需要开启菜单-->
wp_nav_menu();
<!-- 面包屑函数,自定义 -->
lingfeng_breadcrumbs();
single常用
<!-- -------------【single常用】---------------- -->
<!-- 设置文章阅读次数,此方法为重写方法 -->
setPostViews();
<!-- 显示当前文章内容 -->
the_content();
<!-- 下一篇文章 -->
next_post_link()
<!-- 上一篇文章 -->
previous_post_link()
<!-- 开启评论 -->
comments_template()
<!-- 获取指定页面的路径 -->
get_page_link();
获取分类信息函数
<?php
$my_term = get_term_by('name','新闻动态','category');
//var_dump($my_term);
$my_term_ID = $my_term->term_id;
$my_term_name = $my_term->name;
$my_term_link = get_term_link($my_term_ID,'category');
//echo $my_term_link;
?>
<!-- 构成查询器,查询分类文章 -->
<?php $my_query = new WP_Query(array(
'cat' => $my_term_ID, //查询当前级别和子级分类目录下的文章
'posts_per_page' => 1,
//'category_in' => array($my_term_ID,3,4), //查询当前级别和其他分类目录下的文章
)); ?>
<!-- 遍历查询指定文章信息 -->
<?php if ($my_query->have_posts()) : while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
<!-- 调用截取字符串的方法 -->
<a href="<?php the_permalink(); ?>"><img class="post_img" src="<?php echo get_template_directory_uri(); ?>/images/ggg.jpg" alt=""></a>
<a class="post_title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php echo lingfeng_strimwidth( get_the_content(), 100 ) ?>
<?php endwhile; ?>
<?php endif; ?>
未完待续...