码迷,mamicode.com
首页 > 其他好文 > 详细

wordpress-标签

时间:2015-01-21 13:10:44      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

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

主题结构

 1 header.php - header section
 2 index.php - main section
 3 sidebar.php - sidebar section
 4 footer.php - footer section
 5 single.php - post template
 6 page.php - page template
 7 comments.php - comments template
 8 search.php - search content
 9 searchform.php - search form
10 archive.php - archive
11 functions.php - special functions
12 404.php - error page

循环

1 <?php if(have_posts()) : ?>
2    <?php while(have_posts()) : the_post(); ?>
3 // Custom HTML & PHP code
4    <?php endwhile; ?>
5 <?php else : ?>
6 <?php endif; ?>

包含标签

1 < ?php get_header(); ?>
2 < ?php get_sidebar(); ?>
3 < ?php get_footer(); ?>
4 < ?php comments_template(); ?>

网站信息

 1 < ?php bloginfo(‘name‘); ?> - Title of the blog
 2 < ?php bloginfo(‘charset‘); ?> - Displays the character set
 3 < ?php bloginfo(‘description‘); ?> - Displays the description of the blog
 4 < ?php bloginfo(‘url‘); ?> - Displays the address of the blog
 5 < ?php bloginfo(‘rss2_url‘); ?> - Displays the RSS URL
 6 < ?php bloginfo(‘template_url‘); ?> - Displays the URL of the template
 7 < ?php bloginfo(‘pingback_url‘); ?> - Displays the pingback URL
 8 < ?php bloginfo(‘stylesheet_url‘); ?> - Displays the URL for the template‘s CSS file
 9 < ?php bloginfo(‘wpurl‘); ?> - Displays URL for WordPress installation
10 < ?php bloginfo(‘name‘); ?>

判断

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

常用标签

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

导航菜单

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

 

wordpress-标签

标签:

原文地址:http://www.cnblogs.com/fang8580/p/4238485.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!