来源1:http://www.graphicrating.com/2009/01/18/my-wordpress-cheat-sheet/

来源2:http://www.cnblogs.com/asqq/archive/2012/12/26/2833487.html

主题结构

 header.php - header section
 index.php - main section
 sidebar.php - sidebar section
 footer.php - footer section
 single.php - post template
 page.php - page template
 comments.php - comments template
 search.php - search content
 searchform.php - search form
 archive.php - archive
 functions.php - special functions
 404.php - error page

循环

 <?php if(have_posts()) : ?>
    <?php while(have_posts()) : the_post(); ?>
 // Custom HTML & PHP code
    <?php endwhile; ?>
 <?php else : ?>
 <?php endif; ?>

包含标签

 < ?php get_header(); ?>
 < ?php get_sidebar(); ?>
 < ?php get_footer(); ?>
 < ?php comments_template(); ?>

网站信息

 < ?php bloginfo('name'); ?> - Title of the blog
 < ?php bloginfo('charset'); ?> - Displays the character set
 < ?php bloginfo('description'); ?> - Displays the description of the blog
 < ?php bloginfo('url'); ?> - Displays the address of the blog
 < ?php bloginfo('rss2_url'); ?> - Displays the RSS URL
 < ?php bloginfo('template_url'); ?> - Displays the URL of the template
 < ?php bloginfo('pingback_url'); ?> - Displays the pingback URL
 < ?php bloginfo('stylesheet_url'); ?> - Displays the URL for the template's CSS file
 < ?php bloginfo('wpurl'); ?> - Displays URL for WordPress installation
 < ?php bloginfo('name'); ?>

判断

 is_home() - when the user is on the home page(blog)
 is_front_page() - when the user is on the home page (blog or page)
 is_single - when a single post is displayed
 is_sticky() - check if a post is sticky
 is_page() - when a page is displayed
 is_category() - when a category is displayed

常用标签

 < ?php the_time() ?> - Displays the time of the current post
 < ?php the_date() ?> - Displays the date of a post or set of posts
 < ?php the_title(); ?> - Displays or returns the title of the current post
 < ?php the_permalink() ?> - Displays the URL for the permalink
 < ?php the_category() ?> - Displays the category of a post
 < ?php the_author(); ?> - Displays the author of the post
 < ?php the_ID(); ?> - Displays the numeric ID of the current post
 < ?php wp_list_pages(); ?> - Displays all the pages
 < ?php wp_tag_cloud(); ?> - Displays a tag cloud
 < ?php wp_list_cats(); ?> - Displays the categories
 < ?php get_calendar(); ?> - Displays the calendar
 < ?php wp_get_archives() ?> - Displays a date-based archives list
 < ?php posts_nav_link(); ?> - Displays Previous page and Next Page links
 < ?php next_post_link() ?> - Displays Newer Posts link
 < ?php previous_post_link() ?> - Displays previous link

导航菜单

栏目页面
 <ul id="menu">
 <li <?php if(is_home()) { ?> class="current-cat"< ?php } ?>>
 <a href="<?php bloginfo('home'); ?>">Home</a></li>
 < ?php wp_list_categories('title_li=&orderby=id'); ?>
 </ul>
page页面
 <ul id="menu">
 <li <?php if(is_home()) { ?> class="current_page_item"< ?php } ?>>
 <a href="<?php bloginfo('home'); ?>">home</a></li>
 < ?php wp_list_pages('sort_column=menu_order&depth=1&title_li='); ?>
 </ul>

新增

wordpress-标签的更多相关文章

  1. 为 WordPress 标签添加 rel="nofollow" 属性

    WordPress 标签默认并无 rel="nofollow" 属性.rel="nofollow" 属性的作用是:告诉搜索引擎,无需追踪目标页,禁止蜘蛛爬行和传 ...

  2. 修改WordPress标签云字体大小颜色及标签显示数量

    WordPress 自带的标签云是一个很实用的小工具.站长可以通过标签对具有相同关健词的文章进行检索分类,利于访客查找相关文章.WordPress 默认标签云的字体最小为8pt,最大为22pt,标签显 ...

  3. 让wordpress标签云显示文章数的正确方法

    先看一下效果 在百度经验找到一个教程,可惜,根据实践发现方法是错误的, 百度经验上的代码: 1 2 3 4 5 6 7 8 9 10 11 12 //标签tag所包含的文章数量 function Ta ...

  4. WordPress修改标签云大小及颜色

    修改WordPress标签字体大小: 在cpanel面板中依次打开「wp-includes」→「category-template.php」,找到wp_tag_cloud, 1 2 3 4 5 6 7 ...

  5. wordpress模板各文件函数解析

    修改主题时发现好多WordPress主题函数都不了解,因此网上摘抄了一份放在自己博客上,便于以后好找. 在WordPress中如何按你的意愿显示页面,关键看你是否了解WordPress主题模板页面.这 ...

  6. wordpress 获取分类ID,分类标题,分类描述,分类链接url函数

    get_cat_ID()    根据分类名称获取分类ID   ///// get_cat_name()    根据分类ID获取分类名称 用法:<?phpget_cat_ID( $cat_name ...

  7. 代码实现wordpress彩色标签云的最简单的方法

    首先在wordpress主题文件夹内找到并用编辑器打开 functions.php 文件,随意找个位置不到插到别的函数里,“?>” 之前加入以下代码: //彩色标签云 function colo ...

  8. 如何在一小时内更新100篇文章?-Evernote Sync插件介绍

    上一篇"手把手教你制作微信小程序,开源.免费.快速搞定",已经教会你如何快速制作一个小程序,但作为资讯类小程序,内容不可少,并且还需要及时更新. 但是,如果让你复制粘贴,可能还需要 ...

  9. W​o​r​d​P​r​e​s​s​常​用​标​签​和​调​用​总​结

    调用头部模板<?php get_header();?> 调用尾部模板<?php get_footer();?> 调用侧边栏<?php get_sidebar();?> ...

  10. 为wordpress添加Canonical标签

    在 WordPress 2.9 之前,让 WordPress 博客支持 Canonical 标签是需要通过插件或者手工修改主题的 header.php 文件来实现.如在主题中加如下的代码: <? ...

随机推荐

  1. Android消息提示框Toast

    Android消息提示框Toast Toast是Android中一种简易的消息提示框.和Dialog不一样的是,Toast是没有焦点的,toast提示框不能被用户点击,而且Toast显示的时间有限,t ...

  2. spring-jms

    http://haohaoxuexi.iteye.com/blog/1893038 理解PooledConnectionFactory.CachingConnectionFactory和SingleC ...

  3. How to install / setup /upgrade PHP 5.5.x on Ubuntu 12.04 LTS

    原文:http://www.dev-metal.com/how-to-setup-latest-version-of-php-5-5-on-ubuntu-12-04-lts/ 最近遇到了要在ubunt ...

  4. Intergate flot with Angular js ——Angular 图形报表

    下面这篇文章最终的结论就是 Flot 插件 结合 Angular 的Directive 来处理 图表的绘制 给出github上的一个demo源码.https://gist.github.com/fly ...

  5. UINavigationItem不显示

    效果如图: 代码: self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithNormalImage:@"MainTa ...

  6. vpn探测

    root@bt:~# ike-scan -M -v 192.168.1.102 root@bt:~# sslscan 192.168.1.102

  7. 第一个元素<flout>写了,想在他的旁边加一个元素.IE6会出现缝隙. 不要用margin撑开,要用flout

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  8. Robot Framework用法总结

    今天总结下Robot Framework最基本的用法,一来呢,希望自己以后看到这篇总结,很快能回忆起如何使用Robot Framework.二来呢,以初学者的姿态总结Robot Framework,希 ...

  9. iomanip头

    #include <iomanip>主要是输入输出控制. Dec 十进制: hex 十六进制: oct 八进制: setw 设置宽度: setfill 设置填充值: setbase 将数字 ...

  10. DataGridView很详细的用法

    DataGridiew用法总结 一.DataGridView 取得或者修改当前单元格的内容: 当前单元格指的是 DataGridView 焦点所在的单元格,它可以通过 DataGridView 对象的 ...