get_header():调header模板
get_sidebar():调用sidebar模板
get_footer():调用footer模板
get_categories() :获取所有分类列表(只显示有内容的分类列表)
get_category_link($category->term_id) :获取category链接
bloginfo('html_type'):网页html类型
bloginfo('charset'):网页编码
bloginfo('name'):网站名称
bloginfo('url'):网站url
bloginfo('description'):网站描述
bloginfo('stylesheet_url'):css文件路径(style.css)
bloginfo('template_url'):模板文件目录
wp_head():头部挂钩,通过该函数让其他插件或功能函数在网站头部输出css,js等
wp_footer():同上类似
wp_nav_menu():调用导航菜单,一般需要在functions.php添加注册菜单函数 register_nav_menus()一起使用
wp_list_bookmarks() 友情链接函数
the_title():内容页标题
the_permalink():内容页url
the_category():特定内容页所属category
the_author():作者(只显示作者名字,没有链接)
the_author_posts_link():作者(显示作者,并且包含链接到作者文章目录的链接)
the_time('Y-m-d'):显示时间格式化
get_post_meta():获取保存在post_meta这个表的数据,比如输出某个自定义字段的内容
the_ID():特定内容页ID
the_tags('关键字','',''):显示文章的关键tag
the_excerpt():post/page页的摘要,输入文章发布页面中的摘要面板的内容
the_content('more'):显示内容(post/page)全文
wp_list_pages():显示page列表,常用于显示单篇文章的分页,配合 <!–next page-> 来使用
edit_post_link() : 如果用户已登录并具有权限,显示编辑链接
posts_nav_link(); : 显示上一页/下一页的链接,通常用在索引页、分类页和文章存档页
previous_post_link('%link', '上篇', TRUE) : 下一篇文章链接,通常用在单篇文章 single.php 中
php next_post_link('%link', '下篇', TRUE) : 上一篇文章链接,通常用在单篇文章 single.php 中
php comments_popup_link('暂无评论', '评论数 1', '评论数 %') : 正文中的留言链接。如果使用 comments_popup_script(),则留言会在新窗口中打开,反之,则在当前窗口打开
php comments_template( '', true ); :显示评论模块
php include(TEMPLATEPATH . '/xxx/xxxx.php'); : 嵌入其他文件,可为定制的模板或其他类型php文件,很常用
php echo get_avatar( get_the_author_email(), '48' ) :根据作者邮箱输出作者的头像
php wp_list_categories() : 显示Categories列表
php get_calendar() : 日历
php wp_get_archives() : 显示内容存档
php _e('Message') : 输出相应信息
php wp_register() : 显示注册链接
php wp_loginout() : 显示登录/注销链接
php timer_stop(1) : 网页加载时间(秒)
php echo get_num_queries() : 网页加载查询量
single_cat_title():当前分类页标题
single_post_title():当前文章标题
the_post_thumbnail():显示文章缩略图(首先要在functions.php文件加入 缩略图代码add_theme_support('post_thumbnails');
)
只显示文章缩略图链接
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large');
echo $large_image_url[0];
文章没有缩略图时显示占位图片
$image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->id));
if(!$image_url){
//封面图占位
echo "<img src='http://www.zihanzy.com/uploads/images/article_img/202007/25/article_img_1595654106_DhHuMFcqhU.jpg'>";
}else{
the_post_thumbnail();
}