调用头部模板
<?php get_header();?>

调用尾部模板
<?php get_footer();?>

调用侧边栏
<?php get_sidebar();?>

放在head标签内,方便插件调用:
<?php wp_head(); ?>

放在footer里,body结束之前,方便插件调用:
<?php wp_footer(); ?>

----------------------------------------------------------

头部编码调用:
<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" />

头部css调用:
<link href="<?php bloginfo('stylesheet_url'); ?>" rel="stylesheet" type="text/css" media="screen" />

style.css路径调用:
<?php bloginfo( 'stylesheet_url' ); ?>

博客标题:
<?php bloginfo('name'); ?>

博客副标题:
<?php bloginfo('description'); ?>

主页地址:
<?php echo get_option('home'); ?>

<?php bloginfo('home'); ?>

主题模板所在路径:
<?php bloginfo('template_directory'); ?>

----------------------------------------------------------

page页面列表:
<?php wp_list_pages('sort_column=menu_order&title_li=&depth=2&include='); ?>

分类目录列表:
<?php wp_list_categories('title_li=&orderby=name&show_count=0&depth=2'); ?>

----------------------------------------------------------

主循环的开始和结束:
<?php if(have_posts()) : ?>
<?php while(have_posts()) : the_post(); ?>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>

文章的URL地址:
<?php the_permalink() ?>
文章标题:
<?php the_title(); ?>
文章内容:
<?php the_content('Read more...'); ?>
文章摘要:
<?php the_excerpt(); ?>
文章所在分类:
<?php the_category(', ') ?>
文章发布时间:
<?php the_time('Y-m-d') ?>
文章作者:
<?php the_author_posts_link(); ?>
文章评论数量:
<?php comments_number('No comment', '1 comment', '% comments'); ?>
文章标签:
<?php the_tags( 'Tags: ', ', '); ?>

文章评论:
<?php comments_template(); ?>

多页型文章的翻页按钮(调用:<!--nextpage-->):
<?php wp_link_pages(); ?>

----------------------------------------------------------

小工具边栏调用:
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar') ) : ?>
<?php endif; ?>

小工具动态边栏注册(functions.php):
<?php
if ( function_exists('register_sidebar') ) {
    register_sidebar(array(
  'name'=>'Sidebar',
        'before_widget' => '<div class="widget">',
        'after_widget' => '</div>',
        'before_title' => '<h4>',
        'after_title' => '</h4>',
    ));}
?>

自定义菜单调用:
<?php wp_nav_menu(array('theme_location' => 'primary')); ?>

自定义菜单注册(functions.php):
<?php register_nav_menu('primary',__('Primary Navigation')); ?>

----------------------------------------------------------
 
最新文章列表:
<?php wp_get_archives('type=postbypost&limit=10'); ?>

文章按月归档列表:
<?php wp_get_archives('type=monthly'); ?>

RSS地址:
<?php bloginfo('rss2_url'); ?>

标签云:
<?php wp_tag_cloud('smallest=8&largest=32'); ?>

友情链接:
<?php wp_list_bookmarks(); ?>

翻页插件按钮调用:
<?php if(function_exists('wp_pagenavi')) wp_pagenavi(); ?>

列表页面的上一页下一页调用:
<span class="older"><?php previous_posts_link() ?></span>
<span class="newer"><?php next_posts_link() ?></span>

文章页面的上一篇下一篇调用:
<span class="older"><?php previous_post_link(); ?></span>
<span class="newer"><?php next_post_link(); ?></span>

缩略图调用:
<?php the_post_thumbnail(); ?>

缩略图功能启用(functions.php):
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 200, 150, true ); // 普通的缩略图

搜索框调用:
<?php get_search_form(); ?>

在分类页面显示分类名称:
<?php single_cat_title(); ?>
----------------------------------------------------------

style.css版权信息

/*
Theme Name: wpcourse theme
Theme URI: http://www.pprar.com

Description: wpcourse blog theme
Author: ralph
Author URI: http://www.99jianzhu.com

Version: 1.0
Tags: white, simple, blog, wpcourse
*/

----------------------------------------------------------

更多wordpress标签参考:
http://codex.wordpress.org/Function_Reference

----------------------------------------------------------

WP Kit CN 中文工具箱插件可直接调用的标签:
<?php wkc_recent_posts() ?> 显示最新文章
<?php wkc_random_posts() ?> 显示随机文章
<?php wkc_related_posts() ?> 显示相关文章
<?php wkc_posts_in_the_same_categories() ?> 输出同一个分类下的文章
<?php wkc_most_commented_posts() ?> 显示评论最多的文章
<?php wkc_recent_comments() ?> 显示最新评论
<?php wkc_recent_pings() ?> 显示最新pingback和trackback
<?php wkc_most_active_commentors() ?> 显示n天内,评论最多的用户
<?php wkc_recent_commentors() ?> 显示本周或者本月内评论最多的用户
使用说明:
http://sexywp.com/wp-kit-cn-doc
----------------------------------------------------------
调用最新文章列表(方法2):
<?php
 $args = array( 'numberposts' => '10' );
 $recent_posts = wp_get_recent_posts( $args );
 foreach( $recent_posts as $recent ){
  echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a> </li> ';
 }
?>

----------------------------------------------------------
调用某个分类下的最新文章列表:
<?php
 $args = array( 'numberposts' => '5','category'=>'41' );
 $recent_posts = wp_get_recent_posts( $args );
 foreach( $recent_posts as $recent ){
  echo '<li><a href="' . get_permalink($recent["ID"]) . '">'.$recent["post_title"].'</a></li> ';
 }
?>

调用某个分类下的最新文章列表(方法2):
<ul>
<?php
global $post;
$args = array( 'numberposts' => 5, 'category' => 1 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
 <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>

调用某个分类下置顶的文章列表:
<?php
 $args = array( 'numberposts' => '5','category'=>'41' );
 $recent_posts = wp_get_recent_posts( $args );
 foreach( $recent_posts as $recent ){
 if (is_sticky($recent["ID"])) {
  echo '<li><a href="' . get_permalink($recent["ID"]) . '">'.$recent["post_title"].'</a></li> ';
  }
 }
?>

----------------------------------------------------------
面包屑导航:
<?php if(function_exists('bcn_display'))
{
 bcn_display();
}?>
----------------------------------------------------------
在分类页面显示子分类列表:
<?php
$args=array(
  'orderby' => 'name',
  'order' => 'ASC',
  'child_of'  => 1
  );
$categories=get_categories($args);
  foreach($categories as $category) {
    echo '<li class="nav2">
 <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>
 </li>';
    }
?>
----------------------------------------------------------
热评文章列表(functions.php):
<?php function simple_get_most_viewed($posts_num=10, $days=30){
global $wpdb;
$sql = "SELECT ID , post_title , comment_count
FROM $wpdb->posts
WHERE post_type = 'post' AND TO_DAYS(now()) - TO_DAYS(post_date) < $days
ORDER BY comment_count DESC LIMIT 0 , $posts_num ";
$posts = $wpdb->get_results($sql);
$output = "";
foreach ($posts as $post){
$output .= "\n<li><a href= \"".get_permalink($post->ID)."\" rel=\"bookmark\" title=\"".$post->post_title." (".$post->comment_count."条评论)\" >".$post->post_title."</a> </li>";
}
echo $output;
}
?>

----------------------------------------------------------
随机文章列表:
<?php
$rand_posts = get_posts('numberposts=10&orderby=rand');
foreach($rand_posts as $post) : ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach;?>

分类页面调用缩略图(wp_thumbnails插件):
<?php if(function_exists('wp_thumbnails_for_category')) { wp_thumbnails_for_category(); } ?>

W​o​r​d​P​r​e​s​s​常​用​标​签​和​调​用​总​结的更多相关文章

  1. w​i​n​d​o​w​s​ ​s​e​r​v​e​r​ ​2​0​0​8​ ​r​2​ ​启​用​索​引(转)

    08r2的“windows search”服务默认是不安装的,要想启用索引执行下列步骤:        1.打开“服务器管理”——选中“角色”——右边选中“添加角色”——勾选“文件服务”.    2. ...

  2. 【R笔记】R语言函数总结

    R语言与数据挖掘:公式:数据:方法 R语言特征 对大小写敏感 通常,数字,字母,. 和 _都是允许的(在一些国家还包括重音字母).不过,一个命名必须以 . 或者字母开头,并且如果以 . 开头,第二个字 ...

  3. 【R笔记】R语言进阶之4:数据整形(reshape)

    R语言进阶之4:数据整形(reshape) 2013-05-31 10:15 xxx 网易博客 字号:T | T 从不同途径得到的数据的组织方式是多种多样的,很多数据都要经过整理才能进行有效的分析,数 ...

  4. Python获取爬虫数据, r.text 与 r.content 的区别

    1.简单粗暴来讲: text 返回的是unicode 型的数据,一般是在网页的header中定义的编码形式. content返回的是bytes,二级制型的数据. 如果想要提取文本就用text 但是如果 ...

  5. R语言 启动报错 *** glibc detected *** /usr/lib64/R/bin/exec/R: free(): invalid next size (fast): 0x000000000263a420 *** 错误 解决方案

    *** glibc detected *** /usr/lib64/R/bin/exec/R: free(): invalid next size (fast): 0x000000000263a420 ...

  6. velecity报错:Caused by: org.apache.velocity.exception.ParseErrorException: Lexical error, Encountered: <EOF> after : "\'/order/pay?activity=\" + activityId);\r\n }*/\r\n</script>\r\n#end\r\n" at /a

    Caused by: org.apache.velocity.exception.ParseErrorException: Lexical error, Encountered: <EOF> ...

  7. Android中View自己定义XML属性具体解释以及R.attr与R.styleable的差别

    为View加入自己定义XML属性 Android中的各种Widget都提供了非常多XML属性,我们能够利用这些XML属性在layout文件里为Widget的属性赋值. 例如以下所看到的: <Te ...

  8. 批量修改文件权限 和所有者 chown nobody:nobody * -R chmod 775 * -R

    chown nobody:nobody * -R chmod 775 * -R

  9. S​Q​L​_​S​e​r​v​e​r​_​2​0​0​8​定​期​自​动​备​份​详​细​图​解

    S​Q​L​_​S​e​r​v​e​r​_​2​0​0​8​定​期​自​动​备​份​详​细​图​解 设置自动数据库的定期备份计划. http://wenku.baidu.com/link?url=Tu ...

随机推荐

  1. [Node.js] Show More Lines in a Node.js Error Stack Trace

    Sometimes you are one or two lines short from finding the cause of the error in the stack trace but ...

  2. Jacoco覆盖率工具使用之maven篇

    说明 之前的文章已经介绍过如何使用apacheant 执行jacoco工具,下面开始介绍如何使用maven使用jacoco工具. 1.首先新建一个maven项目       如图所示:        ...

  3. 微信小程序 - 回到自己位置(map)

    演示效果: 图片资源 index.js /** * 回到自己位置,在cover-image上绑定点击事件即可. */ clickcontrol(e) { let mpCtx = wx.createMa ...

  4. HTTP——请求和响应格式

    HTTP请求格式:<request-line><headers><blank line>[<request-body>]说明:第一行必须是一个请求行(r ...

  5. 通过 react-native-keyboard-aware-scroll-view 解决键盘遮盖输入框的问题

    1.安装 yarn add react-native-keyboard-aware-scroll-view 2.引入 import { KeyboardAwareScrollView } from ' ...

  6. Tomcat中work目录的作用

    今天在修改了某个jsp后发现:tomcat容器启动后,访问该jsp返回的结果依然是修改之前的内容,略感不解,于是乎研究了一下Tomcat中work目录的作用. Tomcat中work目录的作用: js ...

  7. cocos2d-x 3.0rc2版公布了

    本人博客地址,转载吧亲们:http://blog.csdn.net/dawn_moon 之前做小鸟的和跑酷的时候尽管cocos2d-x出了3.0版,可是还是alpha版.当时大致看了一下发现有蛮多修改 ...

  8. 对象关系映射 EmitMapper 及Tuple的使用

    public TDestination Map<TSource, TDestination>(TSource tSource) { if (tSource == null) return ...

  9. Failed to add reference to 'System.Net.Http'. Please make sure that it is in the Global Assembly Cache.

    关闭VS再来就好了

  10. SPOJ QTREE3 lct

    题目链接 题意: 给定n个点 q个询问 以下n-1行给出树边,点有黑或白色.初始化为白色 以下q行: 询问有2种: 1. 0 x 把x点黑变白,白变黑 2.1 x 询问Path(1,x)路径上第一个黑 ...