您现在的位置是:首页 > cms教程 > WordPress教程WordPress教程
WordPress主题开发常用数据调用介绍
访蕊2025-03-18WordPress教程已有人查阅
导读记录在开发过程中常用的引入标签:在一个模板文件里引用另外一个文件comments_popup_link() ----评论条数
记录在开发过程中常用的
引入标签:在一个模板文件里引用另外一个文件
get_header()
get_footer()
get_sidebar()
get_template_part()
get_search_form()
comments_template() ----引入评论框
bloginfo()
wp_title()
the_title()
the_permalink()
the_content()
the_excerpt()
the_category()
the_tags()
the_time()
comments_popup_link() ----评论条数
edit_post_link()
next_post_link()
previous_post_link()
bloginfo() 显示博客信息,用法:
文章页->文章标题
日期页->日期
分类页->分类标题
作者页->作者名字
用法:
用途:需放主循环内,调用发布信息的标题,在不同文件里,返回的值不一样。
<?php the_permalink(); ?>
the_content()
用途:显示内容,
如果文章插入了more标签
<?php the_content( 'Read more ...' ); ?>
有参数的情况下:
the_excerpt()
用途:调用摘要,如果没有填写摘要则截取文章前55个字符
<?php the_excerpt(); ?>
the_category()
用途:调用当前文章所属分类,必须在主循环内使用
<?php the_category( $separator, $parents, $post_id ); ?>
参数说明:$separator--分隔符,$parents---父目录控制,$post_id---文章编号
只输出当前文章目录:
<?php the_category(); ?>
去格式化输出当前文章目录:
<?php the_category('|'); ?>
子目录和父目录一起调出:
<?php the_category('|','multiple'); ?>
the_tags()
用途:调用当前分类所用的标签
<?php the_tags( $before, $sep, $after ); ?>
参数说明:$before---标签前,$sep--分隔符,$after---标签后
the_time()
用途:调用发表时间,*需放在主循环内
<?php the_time( $d ); ?>
参数说明:$d---时间显示格式
<?php the_time('Y-m-d h:i'); ?>
输出:2017-01-28 12:09
comments_popup_link()
用途:调用评论条数,并带跳转到该文章的评论框的链接,必须在主循环内使用
<?php comments_popup_link( $zero, $one, $more, $css_class, $none ); ?>
参数说明:$zero--没评论的时候显示什么,$one---一条评论的时候显示什么,$more---更多评论的时候显示什么,$css_class---链接的css类,$none---文章不允许评论时显示什么
edit_post_link()
用途:有权限编辑文章时显示的编辑链接,必须在主循环内使用
<?php edit_post_link( $link, $before, $after, $id, $class ); ?>
参数说明:$link---链接文本,$before---链接文本前的文本,$after---链接文本后的文本,$id---文章ID,$class---链接样式
next_post_link(),previous_post_link()
用途:必须在主循环内使用
wordpress函数参考:
英文官方参考网页:http://codex.wordpress.org/Function_Reference/
中文官方参考网页:http://codex.wordpress.org.cn/%E5%87%BD%E6%95%B0%E5%8F%82%E8%80%83
wordpress模版标签:
英文官方参考网页:http://codex.wordpress.org/Template_Tags/
中文官方参考网页:http://codex.wordpress.org.cn/%E6%A8%A1%E6%9D%BF%E6%A0%87%E7%AD%BE
wordpress引入标签:
英文官方参考网页:http://codex.wordpress.org/Include_Tags
中文官方参考网页:http://codex.wordpress.org.cn/Include_Tags
wordpress条件标签:
英文官方参考网页:http://codex.wordpress.org/Conditional_Tags
中文官方参考网页:http://codex.wordpress.org.cn/%E6%9D%A1%E4%BB%B6%E6%A0%87%E7%AD%BE
引入标签:在一个模板文件里引用另外一个文件
get_header()
get_footer()
get_sidebar()
get_template_part()
get_search_form()
comments_template() ----引入评论框
<?php
//调用header.php
get_header();
//调用header-one.php
get_header('one');
?>
<?php
//调用header.php
get_template_part('header');
//调用header-one.php
get_template_part('header','one');
?>
<?php
get_search_form();
//等同
get_search_form(true);
//为false时是赋值,需要另外输出
$form=get_search_form(false);
echo $form;
?>
模版标签:bloginfo()
wp_title()
the_title()
the_permalink()
the_content()
the_excerpt()
the_category()
the_tags()
the_time()
comments_popup_link() ----评论条数
edit_post_link()
next_post_link()
previous_post_link()
bloginfo() 显示博客信息,用法:
<h1><?php bloginfo( 'name' ); ?></h1>
<p><?php bloginfo('description'); ?> </p>
参数:
admin_email = admin@example.com
atom_url = http:// .example.com/home/feed/atom
charset = UTF-8
comments_atom_url = http:// .example.com/home/comments/feed/atom
comments_rss2_url = http:// .example.com/home/comments/feed
description = Just another WordPress blog
home = http:// .example.com/home (DEPRECATED! use url option instead)
html_type = text/html
language = en-US
name = Testpilot
pingback_url = http:// .example.com/home/wp/xmlrpc.php
rdf_url = http:// .example.com/home/feed/rdf
rss2_url = http:// .example.com/home/feed
rss_url = http:// .example.com/home/feed/rss
siteurl = http:// .example.com/home (DEPRECATED! use url option instead)
stylesheet_directory = http:// .example.com/home/wp/wp-content/themes/largo
stylesheet_url = http:// .example.com/home/wp/wp-content/themes/largo/style.css
template_directory = http:// .example.com/home/wp/wp-content/themes/largo
template_url = http:// .example.com/home/wp/wp-content/themes/largo
text_direction = ltr
url = http:// .example.com/home
version = 3.5
wpurl = http:// .example.com/home/wp
wp_title()
用途:通常用在页面头部的<title>元素中,在不同文件里,返回的值不一样,具体如下:文章页->文章标题
日期页->日期
分类页->分类标题
作者页->作者名字
用法:
<?php wp_title( $sep, $display, $seplocation ); ?>
$sep--分隔符,$display--是否直接显示(不直接显示需要echo才出来),$seplocation--分隔符所在位置
the_title()
<?php the_title( $before, $after, $echo ); ?>
参数说明:$before 标题前,$after标题后, $echo是否直接输出用途:需放主循环内,调用发布信息的标题,在不同文件里,返回的值不一样。
<?php if( have_posts() ) : while( have_posts() ) : the_post(); ?>
<!-- 在这里调用数据 -->
<?php the_title();?>
<?php endwhile; ?>
<?php endif; ?>
the_permalink()
用途:调用当前信息的网址,必须在主循环内使用<?php the_permalink(); ?>
the_content()
用途:显示内容,
如果文章插入了more标签
<?php the_content( 'Read more ...' ); ?>
有参数的情况下:
the_excerpt()
用途:调用摘要,如果没有填写摘要则截取文章前55个字符
<?php the_excerpt(); ?>
the_category()
用途:调用当前文章所属分类,必须在主循环内使用
<?php the_category( $separator, $parents, $post_id ); ?>
参数说明:$separator--分隔符,$parents---父目录控制,$post_id---文章编号
只输出当前文章目录:
<?php the_category(); ?>
去格式化输出当前文章目录:
<?php the_category('|'); ?>
子目录和父目录一起调出:
<?php the_category('|','multiple'); ?>
the_tags()
用途:调用当前分类所用的标签
<?php the_tags( $before, $sep, $after ); ?>
参数说明:$before---标签前,$sep--分隔符,$after---标签后
the_time()
用途:调用发表时间,*需放在主循环内
<?php the_time( $d ); ?>
参数说明:$d---时间显示格式
<?php the_time('Y-m-d h:i'); ?>
输出:2017-01-28 12:09
comments_popup_link()
用途:调用评论条数,并带跳转到该文章的评论框的链接,必须在主循环内使用
<?php comments_popup_link( $zero, $one, $more, $css_class, $none ); ?>
参数说明:$zero--没评论的时候显示什么,$one---一条评论的时候显示什么,$more---更多评论的时候显示什么,$css_class---链接的css类,$none---文章不允许评论时显示什么
edit_post_link()
用途:有权限编辑文章时显示的编辑链接,必须在主循环内使用
<?php edit_post_link( $link, $before, $after, $id, $class ); ?>
参数说明:$link---链接文本,$before---链接文本前的文本,$after---链接文本后的文本,$id---文章ID,$class---链接样式
next_post_link(),previous_post_link()
用途:必须在主循环内使用
<?php next_post_link("上一篇: %link") ?>
<?php previous_post_link("下一篇: %link") ?>
更多请参考文档,推荐英文版wordpress函数参考:
英文官方参考网页:http://codex.wordpress.org/Function_Reference/
中文官方参考网页:http://codex.wordpress.org.cn/%E5%87%BD%E6%95%B0%E5%8F%82%E8%80%83
wordpress模版标签:
英文官方参考网页:http://codex.wordpress.org/Template_Tags/
中文官方参考网页:http://codex.wordpress.org.cn/%E6%A8%A1%E6%9D%BF%E6%A0%87%E7%AD%BE
wordpress引入标签:
英文官方参考网页:http://codex.wordpress.org/Include_Tags
中文官方参考网页:http://codex.wordpress.org.cn/Include_Tags
wordpress条件标签:
英文官方参考网页:http://codex.wordpress.org/Conditional_Tags
中文官方参考网页:http://codex.wordpress.org.cn/%E6%9D%A1%E4%BB%B6%E6%A0%87%E7%AD%BE
本文标签:
很赞哦! ()
相关教程
- (响应式)WordPress主题Ripro9.0博客免扩展二开版
- (自适应)WordPress主题SEO自媒体博客资讯模板RabbitV2.0
- WordPress主题模板JustNews资讯博客类源码V5.2.2
- WordPress主题模板主题巴巴/博客X主题源码免费下载
- WordPress主题制作导航的多种方法介绍
- WordPress主题初始化优化教程
- WordPress主题WP_Query基本用法介绍
- 修改WordPress主题的方法
- 自己动手制作WordPress主题步骤教程
- wordpress主题信息的删除方法
- WordPress主题怎么加密,WordPress主题加密怎么破解
- wordpress主题更改语言的方法
图文教程
wordpress建站好用吗,wordpress建站可以吗
用wordpress建站当然是可以的,在WordPress面前,建站是一个已经解决的问题不能说的网站,但95%以上的网站,都可以用WordPress配合优质主题快速搭建上线
WordPress文章页怎么添加展开收缩功能
很多时候我们在WordPress上发布一些文章的时候里面都包含了很多的代码,我一般又不喜欢把代码压缩起来而喜欢让代码格式化显示,但是格式化显示通常会让文章内容看起来很多
wordpress备份数据库的步骤
wordpress如何备份数据库,以下是在WordPress中的数据库备份的简单步骤
wordpress关键词和描述添加代码实例
wordpress官方下载安装的程序,只能填写网站标题和副标题,通过插件来添加却又担心会影响网站的整体使用出错
相关源码
-
(PC+WAP)智能机器人人工智能物联网自动化设备源码下载本模板基于PbootCMS内核开发,为智能机器人及传感器科技企业精心设计。采用现代化设计风格,突出科技感与专业性,多方位展示企业技术实力与产品优势。查看源码 -
(自适应)品牌策划网络设计作品公司个人pbootcms网站源码下载本款基于PbootCMS开发的网站模板专为品牌策划、设计公司打造,特别适合展示创意作品、设计案例和企业服务。模板采用现代化设计风格查看源码 -
(响应式)轴承机械五金零件产品pbootcms落地推广单页源码下载为轴承、机械零件等工业产品打造的响应式单页模板,基于PbootCMS内核开发,助力企业快速构建专业级产品展示页面。模板采用工业风设计语言,突出产品参数与性能优势,适用于设备制造商、零部件供应商等B2B场景推广。查看源码 -
宽屏自适应搬家家政快递物流公司网站模板该宽屏大气的响应式网站模板专为搬家公司、家政服务及物流快递企业设计,基于PbootCMS内核开发,通过自适应布局确保手机、PC等多终端体验一致,助力企业高效构建专业在线服务平台。查看源码 -
(PC+WAP)蓝色钢材加工建筑装修施工材料网站模板下载为钢材加工企业设计的PbootCMS响应式模板,采用PC+WAP双端适配技术,数据实时同步。简洁大气的蓝色工业风格设计,突出钢材加工行业特性,其他制造业用户更换图文内容即可快速应用。查看源码 -
(PC+WAP)高端餐饮美食小吃加盟网站模板下载pbootcms本模板基于PbootCMS内核开发,为餐饮美食品牌加盟、小吃连锁企业量身打造。通过精致的美食视觉呈现与加盟业务流程展示,帮助餐饮企业建立专业线上门户,实现品牌形象与加盟业务的双重展示。查看源码
| 分享笔记 (共有 篇笔记) |

