WordPress模板结构
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_home() : 是否为主页
is_single() : 是否为内容页(Post)
is_page() : 是否为内容页(Page)
is_category() : 是否为Category/Archive页
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页是否以多页显示
-----------------------------------------------------------------------------------
style.css头部主题注释文字
3 |
Theme URI: http://www.1990c.com |
5 |
Author URI: http://www.1990c.com |
6 |
Description: Lin Yunpeng's theme |
-----------------------------------------------------------------------------------
header.php常用标签
1 |
<pre>style.css路径<?php bloginfo( 'stylesheet_url' ); ?> |
2 |
主题文件夹路径<?php bloginfo( 'template_directory' ); ?> |
3 |
主页路径<?php echo get_option( 'home' ); ?> |
4 |
wordpress编码<?php bloginfo( 'charset' ); ?> |
07 |
{the_title(); print " - " ;bloginfo( 'name' ); } |
08 |
else if (is_category()) |
09 |
{single_cat_title(); print " - " ;bloginfo( 'name' ); } |
11 |
{ bloginfo( 'name' ); print " - " ;bloginfo( 'description' ); } |
07 |
$categories =get_categories( $args ); |
08 |
foreach ( $categories as $category ) { |
09 |
echo '<li class="thisclass"><a href="' . get_category_link( $category ->term_id ) . '" title="' . sprintf( __( "View all posts in %s " ), $category->name ) . '" ' . '>' . $category ->name. '</a></li>' ; |
-----------------------------------------------------------------------------------
sidebar.php常用标签
2 |
<?php $rand_posts = get_posts( 'numberposts=9&orderby=date' ); foreach ( $rand_posts as $post ) : ?> |
3 |
<li><a href= "<?php the_permalink(); ?>" ><?php the_title(); ?></a></li> |
2 |
<?php $rand_posts = get_posts( 'numberposts=9&orderby=rand' ); foreach ( $rand_posts as $post ) : ?> |
3 |
<li><a href= "<?php the_permalink(); ?>" ><?php the_title(); ?></a></li> |
-----------------------------------------------------------------------------------
index.php常用标签
1 |
调用head.php<?php get_header();?> |
2 |
调用footer.php<?php get_footer();?> |
3 |
调用sidebar.php<?php get_sidebar();?> |
4 |
调用其它文件<?php include (TEMPLATEPATH . '/文件名' ); ?> |
5 |
显示注册链接<?php wp_register(); ?> |
6 |
显示登录/注销链接<?php wp_loginout(); ?> |
02 |
<?php if (have_posts()) : ?> /*检查是否存在Post/Page*/ |
03 |
<?php while (have_posts()) : the_post(); ?> /*如果存在Post/Page则予以显示 */ |
04 |
<?php the_title(); ?> /*文章标题*/ |
05 |
<?php the_time( 'Y.m.d h:i' ) ?> /*发表时间*/ |
06 |
<?php the_category( ' ' ); ?> /*文章分类*/ |
07 |
<?php comments_popup_link( '0' , '1' , '%' , ”, 'CLOSE' ); ?> /*评论数*/ |
08 |
<?php edit_post_link( 'EDIT' ); ?> /*显示编辑链接*/ |
09 |
<?php the_content( '' ); ?> /*正文内容*/ |
10 |
<?php endwhile ; ?> /*While结束*/ |
11 |
<?php endif ; ?> /*If结束*/ |
-----------------------------------------------------------------------------------
single.php常用标签
1 |
上一篇<?php previous_post_link( '%link' ); ?> |
2 |
下一篇<?php next_post_link( '%link' ); ?> |
3 |
评论调用<?php comments_template(); ?> |
4 |
日历调用<?php get_calendar(); ?> |
- wordpress主题制作常用基本的模板及说明
style.css : CSS(样式表)文件,一般包括主题声明和通用css样式代码 index.php : 主页模板,一般用来做网站的首页 header.php : Header模板,一般是所有页面的 ...
- CSS网页制作常用标签
做了一个简单的网页,从布局到加内容,遇到了很多小问题.很多标签和属性都不会用或者忘记了.所以以此记录一下. 一.如何将边框四角变圆?(或做一个圆形) 顾名思义,如果要更改边框的角需要用到边框(bord ...
- phpcms v9模板制作常用代码集合(转)
phpcms v9模板制作常用代码集合(个人收藏) 1.截取调用标题长度 {str_cut($r[title],36,'')} 2.格式化时间 调用格式化时间 2011-05-06 11:22:33 ...
- WP主题模板制作修改教程
WP主题模板制作修改教程 实际上,当我们打开某个主题的文件夹时,看到的并不止这两个文件,而是更多.但一般来说,在一个完整的 WP 主题文件夹中都应该包含下列文件(也称为模板文件):页面 模板文件 用途 ...
- phpcms v9模板制作常用代码集合
phpcms v9模板制作常用代码集合(个人收藏) 1.截取调用标题长度 {str_cut($r[title],36,'')} 2.格式化时间 调用格式化时间 2011-05-06 11:22:33 ...
- HTML常用标签
HTML常用标签: HTML文档格式: 首先,HTML是一种超文本标签语言,它是制作网页的基础. 其次,HTML文档中至少包含基本的和成对的<html> </html>.< ...
- 9月5日网页基础知识 通用标签、属性(body属性、路径、格式控制) 通用标签(有序列表、无序列表、常用标签)(补)
网页基础知识 一.HTML语言 HTML语言翻译汉语为超文本标记语言. 二.网页的分类 1.静态页面:在静态页面中修改网页内容实际上就是修改网页原代码,不能从后台操作,数据来只能来源于原于代码.静态网 ...
- 对HTML的理解及常用标签使用介绍--来自我的百度前端技术学院的笔记
HTML是什么,HTML5是什么? ——HTML:超文本标记语言,一种用于创建网页的标准标记语言: ——HTML5:目前最新的HTML标准,包含新的元素.属性.行为,基于它们的功能特征将他们分成不同的 ...
- 4-[HTML]-body常用标签1
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
随机推荐
- python 静态方法,类方法 ,类的继承
转自: http://cowboy.1988.blog.163.com/blog/static/75105798201091141521583/ 1.关于定义类的一些奇特之处 今天在Python中 ...
- [Leetcode][JAVA] Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. ...
- [Leetcode][JAVA] Word Ladder
Given two words (start and end), and a dictionary, find the length of shortest transformation sequen ...
- web压力测试工具
ab apache 自带的web压力测试工具,window和linux下均有. 命令行:./ab -c 100 -n 1000 http://www.baidu.com 说明: -c 表示同时处理10 ...
- azure存储压测的问题(农码主观意识太强被坑了)
由于公司想把部份业务迁到windowsazure,主要是应用winodwsazure的存储;在方案中为了体现存储的可靠性所以对winodwsazure存储进行了一系列的测试.但在读取压力测试环节中发现 ...
- 修改开机启动等待时间(for Ubuntu12.10)
Ubuntu的开机启动等待时间默认是10s,等待时间比较长,每次启动都得按一下回车,于是就想修改一下等待时间.我们可以找到Grub的配置文件(/boot/grub/grub.cfg),在其中进行个性化 ...
- Asp.Net Web API 2第十四课——Content Negotiation(内容协商)
前言 阅读本文之前,您也可以到Asp.Net Web API 2 系列导航进行查看 http://www.cnblogs.com/aehyok/p/3446289.html 本文描述ASP.NET W ...
- UML建模语言入门 -- 用例视图详解 用例视图建模实战
. 作者 :万境绝尘 转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/18964835 . 一. 用例视图概述 用例视图表述哪些 ...
- hibernate 问题集
1.Could not obtain transaction-synchronized Session for current thread 解决方法: 在web.xml中加入如下配置: <fi ...
- 使用ThreadSanitizer线程检查工具
ThreadSanitizer又叫TSan,是一个检查线程Data Race的C/C++工具.它集成在新版的gcc和clang中,通过编译时加-fsanitize=thread,可以在运行时检测出Da ...