作者: Chris Coyier and Jeff Starr
出版社: Digging into WordPress
出版年: 2011-5-1
页数: 420
定价: USD 75.00
装帧: Spiral-bound
ISBN: 9780983517801
出版社: Digging into WordPress
出版年: 2011-5-1
页数: 420
定价: USD 75.00
装帧: Spiral-bound
ISBN: 9780983517801
豆瓣成员常用的标签(共5个) · · · · · ·
按有用程度 按页码先后 最新笔记
-
全书笔记
valdanito (平凡有另一个名字)
wordpress 3.3.1 的新功能 ======================== 可以修改或去掉默认的uncategoried分类。 tips ==== 创建的分类最好不要超过15个,tags最好不要超过100个 自定义taxonomies ================ /代码内容已省略/ 在主题里插入tag_cloud /代码内容已省略/ 在主题里调用自定义tag下的文章 /代码内容... (更多)wordpress 3.3.1 的新功能========================可以修改或去掉默认的uncategoried分类。tips====创建的分类最好不要超过15个,tags最好不要超过100个自定义taxonomies================function creat_my_taxonomies(){ register_taxonomy('actor','post',array( 'hierarchial' => false, 'label' => 'Actors', 'query_var' => true, 'rewrite' => true)); } add_action('init','creat_my_taxonomies',0);在主题里插入tag_cloud<?php wp_tag_cloud(array('taxonomy' => 'people', 'number'=>45));?>在主题里调用自定义tag下的文章<?php query_post(array('people' => 'will-smith', 'showposts'=>10));?>在文章中列举某个taxonomy分类下的tags,以下列举的是people下的<?php echo get_the_term_list($post->ID, 'people','People:',','','');?>
function exists判断插件是否存在==============================<?php if(function_exists('get_poll')){get_poll();}?>推荐的插件==========vaultpress : 云备份art direction : 在post/page里插入css/js 以自定义文章风格feedburner feedsmith : 查看feeds订阅w3 total cache : 数据缓存wp-dbmanager : 数据备份和缓存posts per page / custom post limits : 改变页面文章显示的数量post editor buttons : 自定义文章编辑按钮wordpress seo by yoast : seo插件google xml sitemaps : 创建xml sitemapsclean notifications : 创建自己的email通知邮件模板subscribe to comments : 有评论回复邮件提醒模板文件优先级===============p57single: single-{post-type}.php > single.php >index.phppage: {custom-template}.php > page-{slug}.php > page-{id}.php > page.php >index.php全能title=========代码::<title> <?php if (function_exists('is_tag') && is_tag()) { single_tag_title('Tag Archive for "'); echo '" - '; } elseif (is_archive()) { wp_title(''); echo ' Archive - '; } elseif (is_search()) { echo 'Search for "'.wp_specialchars($s).'" - '; } elseif (!(is_404()) && (is_single()) || (is_page())) { wp_title(''); echo ' - '; } elseif (is_404()) { echo 'Not Found - '; } if (is_home()) { bloginfo('name'); echo ' - '; bloginfo('description'); } else { bloginfo('name'); } if ($paged > 1) { echo ' - page '. $paged; } ?> </title>插入jquery===========<?php wp_enqueue_script('jquery');?>Global Custom Fileds====================p66 LOOP=====<?php if(have_post()):while(have_post()):the_post(); endwhile;else: endif; ?>
LOOP ONLY 函数==============the_title()the_permalink()the_ID()the_author()the_category()$post->ID$post->post_content$post->post_modified$post->post_name return the slug of the post更多函数请看 digwp.com/u/399Outside Loop 函数=================wp_list_pages()next_posts_link()wp_tag_cloud()get_permalink()Comments 的逻辑===============1.是否文章受保护(需输入密码)2.是否有评论3.是否评论开放4.是否需要登陆Sidebar=======<?php get_sidebar();?>
<?php get_sidebar('secondary');?> 读取sidebar-secondary.phpSearchForm==========<?php get_search_form();?> 很遗憾get_serch_form不接受任何参数改变searchform的路径<?php include(TEMPLATEPATH.'/inc/special-search-form.php';?>插件: search everythingThe Footer==========<?php get_footer();?><?php get_footer("mini");?> footer-mini.php自定义LOOP==========query_post() 用于单个loop 修改默认的loopWP_Query() 用于多个loopget_post() 通常用于在侧栏页尾加入自定义loop 创建静态loop和附加loopquery_post-----------<?php // The WordPress Loop - customized with query_posts global $query_string; // grab the global query information $posts = query_posts($query_string.'&cat=-9'); // exclude Asides category if (have_posts()) : while (have_posts()) : the_post(); endwhile; else: endif; wp_reset_query(); // reset the query ?>query_post 会影响is_page()和is_single()的模板标签。WP_Query---------<?php // The WordPress Loop - customized with WP_Query $custom_query = new WP_Query('cat=-9'); // exclude Asides category while($custom_query->have_posts()) : $custom_query->the_post(); endwhile; wp_reset_postdata(); // reset the query ?>支持翻页 &paged = .$pagedwprdpress 3.3.1 的新特性: is_main_query()get_posts=========<?php // additional loop via get_posts global $post; $args = array('category' => -9); // exclude Asides category $custom_posts = get_posts($args); foreach($custom_posts as $post) : setup_postdata($post); endforeach; ?>get_posts 不支持翻页 post-navigation 及 next_posts_link 和 previous_posts_link多重loop: http://perishablepress.com/press/tag/loops/显示最近的评论、最新的文章、最受欢迎的文章==========================================p110-112常用的CSS Reset ================Eric Meyer's Reset Reloaded http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/ YUI http://developer.yahoo.com/yui/reset/CSS 压缩======== http://www.cssoptimiser.com/Mobile主题=========WPtouch http://wordpress.org/extend/plugins/wptouch/ Mobify http://mobify.me声明自己的widgetized area=========================code::<?php if (!function_exists('dynamic_sidebar') ||!dynamic_sidebar('Sidebar Widgets')) :?> Content in here will ONLY show if there are no widgets active,or if the version of WordPress running doesn't support widgets.Otherwise, this area is where the widgets go, set via the Admin <?php endif; ?>在functions里激活::if (function_exists('register_sidebar')) { register_sidebar(array( 'name'=>'Sidebar Widgets', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h4 class="widgettitle">', 'after_title' => '</h4>', )); }显示文章被编辑的时间====================需要放到loop里::<p>Updated on <?php $x = get_the_time('U'); $m = get_the_modified_time('U'); if ($m != $x) { the_modified_time('F d, Y'); } ?></p>停止自动更新提示===============p144<?php add_action('admin_menu', create_function('$a', "remove_action('load-plugins.php', 'wp_update_plugins');")); add_filter('pre_option_update_plugins', create_function('$a', "return null;")); add_action('init', create_function('$a', "remove_action('init', 'wp_version_check');")); add_filter('pre_option_update_core', create_function('$a', "return null;")); ?>在前台添加删除和报spam评论==========================function spam_delete_links($id) { global $id; if (current_user_can('edit_post')) { echo ' | <a href="'.get_bloginfo('wpurl').'/wp-admin/comment.php? action=cdc&c='.$id.'">Delete</a>'; echo ' | <a href="'.get_bloginfo('wpurl').'/wp-admin/comment.php? action=cdc&dt=spam&c='.$id.'">Spam</a>'; } }调用<?php spam_delete_links(get_comment_ID());?>Shortcode=========<?php // shortcode for homepage linkfunction myHomePage() {return '<a href=""title="My Website Homepage">My Homepage</a>';} add_shortcode('home', 'myHomePage');?>文章缩略图==========<?php if(functin_exist('add_theme_support')){add_theme_support('post-thumbnails');}?>调用<?php the_post_thumbnail();?>
自定义区域 Custom Fields========================<?php get_post_meta($post_id, '$key', $single); ?>
tutorials : http://perishablepress.com/press/2008/12/17/wordpress-custom-fields-tutorial/ http://perishablepress.com/press/2008/12/22/wordpress-custom-fields-tips-tricks/wordpress翻页插件=================wp-pagenavi 最流行的breadcrumb 面包屑wordpress navigation list plugin Navt 据说交互好,没用过wp dtree 导航树sub pages widget 展示当前页面的子页面更多cms插件: http://digwp.com/2012/01/wordpress-cms-plugins/Wordpress Feeds================<?php bloginfo('rss2_url'); ?> - RSS 2.0 format<?php bloginfo('rss_url'); ?> - RSS 0.92 format<?php bloginfo('rdf_url'); ?> - RDF/RSS 1.0 format<?php bloginfo('atom_url'); ?> - Atom format给atom feed 添加图标function mwp_atomImage() { echo " <icon>http://digwp.com/images/favicon.ico</icon> <logo>http://digwp.com/images/feed-icon.png</logo> "; } add_action('atom_head', 'mwp_atomImage');给你的wordpress理发===================去掉在wp-head的版本号<?php remove_action('wp_head', 'wp_generator'); ?>其它remove_action('wp_head', 'rsd_link');remove_action('wp_head', 'wp_generator');remove_action('wp_head', 'feed_links', 2);remove_action('wp_head', 'index_rel_link');remove_action('wp_head', 'wlwmanifest_link');remove_action('wp_head', 'feed_links_extra', 3);remove_action('wp_head', 'start_post_rel_link', 10, 0 );remove_action('wp_head', 'parent_post_rel_link', 10, 0);remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);在feeds里添加自定义内容=======================function insertContent($content) { $content = $content . '<p>Place your custom content here!</p>'; return $content; } add_filter('the_excerpt_rss', 'insertContent'); add_filter('the_content_rss', 'insertContent');评论====<ol> <?php wp_list_comments();?> </ol>p220自定义评论<ul class="commentlist"> <?php wp_list_comments('type=comment&callback=mytheme_comment'); ?> </ul>需要在functions里写自己的mytheme_comment函数 http://codex.wordpress.org/Template_Tags/wp_list_comments调用评论翻页============<?php previous_comments_link();?> <?php ext_comments_link();?>
消除多页重复评论插件:: SEO for Paged Comments添加自己的thread comment功能p226分割评论和trackback===================<h3>Comments</h3> <ol class="comments"> <?php wp_list_comments('type=comment'); ?> </ol> <h3>Pingbacks/Trackbacks</h3> <ol class="pingbacks-trackbacks"> <?php wp_list_comments('type=pings'); ?> </ol>更清新的Pingback和Trackbacks输出================================function cleanPings($comment, $args, $depth) { $GLOBALS['comment'] = $comment; echo '<li>'.comment_author_link().'</li>'; }为wp_list_comments 添加callback--------------------------------<?php wp_list_comments('type=pings&callback=cleanPings'); ?>只在pingsback/trackbacks有内容时显示-------------------------------------p232local comments number---------------------<?php $commentcount = 1 // number of first comment ?> <p class="comment-count"><a href="#comment-<?php comment_ID(); ?>">#<?php echo $commentcount++; ?></a></p>
或者<a href="<?php the_permalink(); ?>#comment-<?php comment_ID(); ?>" id="comment-<?php comment_ID(); ?>" title="Permalink for comment #<?php echo $comment_count; ?>">Comment #<?php echo $comment_count; ?></a>
只统计评论数目--------------function countComments($count) { global $wp_query; return count($wp_query->comments_by_type['comment']); } add_filter('get_comments_number', 'countComments', 0);自定义评论的风格---------------#. 奇数和偶数行#. 作者和成员<?php foreach ($comments as $comment) : ?> <div<?php if ($comment->user_id == $post->post_author) { echo ' class="comment-author"'; } ?>> <p><strong><?php comment_author_link(); ?></strong></p> <?php comment_text(); ?> </div> <?php endforeach; ?>p242gravatar--------添加在comments loop里:<?php if(function_exists('get_avatar')) { echo get_avatar($comment, $size = '50', $default = 'http://domain.tld/default.png'); } ?>在文章里添加gravatar<?php $author_email = get_the_author_email(); echo get_avatar($author_email,'96'); ?>
twitter avatar--------------<?php twitter('50','http://domain.tld/default.png','#ffffff','twitavatars',1,'G');?>改变评论排序,让最新的在最前----------------------------<?php $comments = array_reverse($comments, true); ?> <?php foreach ($comments as $comment) : ?> <?php comment_author_link(); ?> <?php comment_text() ?> <?php endforeach; ?>
防治垃圾评论------------ http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/ 插件:: Akismet Peter's Custom Anti-Spam reCAPTCHA Plugin WP-HashCash Simple Trackback ValidationSEO---p261更安全的WP-----------p299改变数据库前缀 p314php压缩 http://perishablepress.com/press/2007/03/26/fast-effective-php-compression/反盗链<IfModule mod_rewrite.c>RewriteEngine onRewriteCond %{HTTP_REFERER} !^$RewriteCond %{REQUEST_FILENAME} -fRewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$ [NC]RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?domain\. [NC]RewriteRule \.(gif|jpe?g?|png)$ - [F,NC,L]</ifModule>http://perishablepress.com/press/2007/11/21/creating-the-ultimate-htaccess-anti-hotlinking-strategy/Nonus Tricks=============添加theme options p346自定义主题目录=============<?php register_theme_directory('alt-themes'); ?>alt-theme 相对于wp-content 路径Multisite=========p378Custom Taxonomies=================p383Custom Menus============function register_menus() { register_nav_menus( array( 'primary-menu' => __('Primary Menu'), 'secondary-menu' => __('Secondary Menu'), 'tertiary-menu' => __('Tertiary Menu') ) ); } add_action('init', 'register_menus'); <?php wp_nav_menu( array( 'theme_location' => 'primary-menu' ) ); ?>Custom Post Types=================p387ShortLink==========<?php the_shortlink('shortlink', null, '<p>', '</p>'); ?>wp3.0 添加了新的comment_form函数================================<?php comment_form();?>
wp3.1的新功能==============custom post format-------------------改变post的样式已适应内容,10种post_format:: • Standard – A regular blog post (no format) • Aside – Small blurbs, random thoughts, etc. • Chat – Dialogue from instant messaging and chat • Gallery – Groups of images or other media files • Image – Any image • Link – Cool links to awesome resources • Quote – Any quote • Status – Updates to 3rd-party services, like Twitter • Video – Any video, screencast, slideshow, etc. • Audio – Any audio clip, song, or podcast只支持 custom_post formatsadd_theme_support('post-formats',array('aside','chat','gallery','image','link','quote','status','video','audio'));使用post_formatspost format tags:: set_post_format() get_post_format() get_post_format_link() get_post_format_string() has_post_format()post format classes:: .format-aside .format-gallery .format-link .format-image .format-quote .format-status .format-video .format-audio .format-chatAdvanced Custom Field Queries=============================p397 http://codex.wordpress.org/Function_Reference/WP_Query#Custom_Field_ParametersAdvanced Taxonomy Queries==========================p399-400tax_query examples:: http://ottopress.com/2010/wordpress-3-1-advanced-taxonomy-queries/User Queries=============get_users 函数::<?php // display a list of subscriber emails $blogusers = get_users('blog_id=1&orderby=nicename&role=subscriber'); echo '<ul>'; foreach ($blogusers as $user) { echo '<li>' . $user->user_email . '</li>'; } echo '</ul>'; ?>docs:: http://codex.wordpress.org/Function_Reference/get_usersWP 3.3 的关键特性=================#. wp_editor API#. jquery upgrade#. is_main_query()#. post-format (收起)2012-02-12 21:18:25 1人收藏 回应
-
全书笔记
valdanito (平凡有另一个名字)
wordpress 3.3.1 的新功能 ======================== 可以修改或去掉默认的uncategoried分类。 tips ==== 创建的分类最好不要超过15个,tags最好不要超过100个 自定义taxonomies ================ /代码内容已省略/ 在主题里插入tag_cloud /代码内容已省略/ 在主题里调用自定义tag下的文章 /代码内容... (更多)wordpress 3.3.1 的新功能========================可以修改或去掉默认的uncategoried分类。tips====创建的分类最好不要超过15个,tags最好不要超过100个自定义taxonomies================function creat_my_taxonomies(){ register_taxonomy('actor','post',array( 'hierarchial' => false, 'label' => 'Actors', 'query_var' => true, 'rewrite' => true)); } add_action('init','creat_my_taxonomies',0);在主题里插入tag_cloud<?php wp_tag_cloud(array('taxonomy' => 'people', 'number'=>45));?>在主题里调用自定义tag下的文章<?php query_post(array('people' => 'will-smith', 'showposts'=>10));?>在文章中列举某个taxonomy分类下的tags,以下列举的是people下的<?php echo get_the_term_list($post->ID, 'people','People:',','','');?>
function exists判断插件是否存在==============================<?php if(function_exists('get_poll')){get_poll();}?>推荐的插件==========vaultpress : 云备份art direction : 在post/page里插入css/js 以自定义文章风格feedburner feedsmith : 查看feeds订阅w3 total cache : 数据缓存wp-dbmanager : 数据备份和缓存posts per page / custom post limits : 改变页面文章显示的数量post editor buttons : 自定义文章编辑按钮wordpress seo by yoast : seo插件google xml sitemaps : 创建xml sitemapsclean notifications : 创建自己的email通知邮件模板subscribe to comments : 有评论回复邮件提醒模板文件优先级===============p57single: single-{post-type}.php > single.php >index.phppage: {custom-template}.php > page-{slug}.php > page-{id}.php > page.php >index.php全能title=========代码::<title> <?php if (function_exists('is_tag') && is_tag()) { single_tag_title('Tag Archive for "'); echo '" - '; } elseif (is_archive()) { wp_title(''); echo ' Archive - '; } elseif (is_search()) { echo 'Search for "'.wp_specialchars($s).'" - '; } elseif (!(is_404()) && (is_single()) || (is_page())) { wp_title(''); echo ' - '; } elseif (is_404()) { echo 'Not Found - '; } if (is_home()) { bloginfo('name'); echo ' - '; bloginfo('description'); } else { bloginfo('name'); } if ($paged > 1) { echo ' - page '. $paged; } ?> </title>插入jquery===========<?php wp_enqueue_script('jquery');?>Global Custom Fileds====================p66 LOOP=====<?php if(have_post()):while(have_post()):the_post(); endwhile;else: endif; ?>
LOOP ONLY 函数==============the_title()the_permalink()the_ID()the_author()the_category()$post->ID$post->post_content$post->post_modified$post->post_name return the slug of the post更多函数请看 digwp.com/u/399Outside Loop 函数=================wp_list_pages()next_posts_link()wp_tag_cloud()get_permalink()Comments 的逻辑===============1.是否文章受保护(需输入密码)2.是否有评论3.是否评论开放4.是否需要登陆Sidebar=======<?php get_sidebar();?>
<?php get_sidebar('secondary');?> 读取sidebar-secondary.phpSearchForm==========<?php get_search_form();?> 很遗憾get_serch_form不接受任何参数改变searchform的路径<?php include(TEMPLATEPATH.'/inc/special-search-form.php';?>插件: search everythingThe Footer==========<?php get_footer();?><?php get_footer("mini");?> footer-mini.php自定义LOOP==========query_post() 用于单个loop 修改默认的loopWP_Query() 用于多个loopget_post() 通常用于在侧栏页尾加入自定义loop 创建静态loop和附加loopquery_post-----------<?php // The WordPress Loop - customized with query_posts global $query_string; // grab the global query information $posts = query_posts($query_string.'&cat=-9'); // exclude Asides category if (have_posts()) : while (have_posts()) : the_post(); endwhile; else: endif; wp_reset_query(); // reset the query ?>query_post 会影响is_page()和is_single()的模板标签。WP_Query---------<?php // The WordPress Loop - customized with WP_Query $custom_query = new WP_Query('cat=-9'); // exclude Asides category while($custom_query->have_posts()) : $custom_query->the_post(); endwhile; wp_reset_postdata(); // reset the query ?>支持翻页 &paged = .$pagedwprdpress 3.3.1 的新特性: is_main_query()get_posts=========<?php // additional loop via get_posts global $post; $args = array('category' => -9); // exclude Asides category $custom_posts = get_posts($args); foreach($custom_posts as $post) : setup_postdata($post); endforeach; ?>get_posts 不支持翻页 post-navigation 及 next_posts_link 和 previous_posts_link多重loop: http://perishablepress.com/press/tag/loops/显示最近的评论、最新的文章、最受欢迎的文章==========================================p110-112常用的CSS Reset ================Eric Meyer's Reset Reloaded http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/ YUI http://developer.yahoo.com/yui/reset/CSS 压缩======== http://www.cssoptimiser.com/Mobile主题=========WPtouch http://wordpress.org/extend/plugins/wptouch/ Mobify http://mobify.me声明自己的widgetized area=========================code::<?php if (!function_exists('dynamic_sidebar') ||!dynamic_sidebar('Sidebar Widgets')) :?> Content in here will ONLY show if there are no widgets active,or if the version of WordPress running doesn't support widgets.Otherwise, this area is where the widgets go, set via the Admin <?php endif; ?>在functions里激活::if (function_exists('register_sidebar')) { register_sidebar(array( 'name'=>'Sidebar Widgets', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h4 class="widgettitle">', 'after_title' => '</h4>', )); }显示文章被编辑的时间====================需要放到loop里::<p>Updated on <?php $x = get_the_time('U'); $m = get_the_modified_time('U'); if ($m != $x) { the_modified_time('F d, Y'); } ?></p>停止自动更新提示===============p144<?php add_action('admin_menu', create_function('$a', "remove_action('load-plugins.php', 'wp_update_plugins');")); add_filter('pre_option_update_plugins', create_function('$a', "return null;")); add_action('init', create_function('$a', "remove_action('init', 'wp_version_check');")); add_filter('pre_option_update_core', create_function('$a', "return null;")); ?>在前台添加删除和报spam评论==========================function spam_delete_links($id) { global $id; if (current_user_can('edit_post')) { echo ' | <a href="'.get_bloginfo('wpurl').'/wp-admin/comment.php? action=cdc&c='.$id.'">Delete</a>'; echo ' | <a href="'.get_bloginfo('wpurl').'/wp-admin/comment.php? action=cdc&dt=spam&c='.$id.'">Spam</a>'; } }调用<?php spam_delete_links(get_comment_ID());?>Shortcode=========<?php // shortcode for homepage linkfunction myHomePage() {return '<a href=""title="My Website Homepage">My Homepage</a>';} add_shortcode('home', 'myHomePage');?>文章缩略图==========<?php if(functin_exist('add_theme_support')){add_theme_support('post-thumbnails');}?>调用<?php the_post_thumbnail();?>
自定义区域 Custom Fields========================<?php get_post_meta($post_id, '$key', $single); ?>
tutorials : http://perishablepress.com/press/2008/12/17/wordpress-custom-fields-tutorial/ http://perishablepress.com/press/2008/12/22/wordpress-custom-fields-tips-tricks/wordpress翻页插件=================wp-pagenavi 最流行的breadcrumb 面包屑wordpress navigation list plugin Navt 据说交互好,没用过wp dtree 导航树sub pages widget 展示当前页面的子页面更多cms插件: http://digwp.com/2012/01/wordpress-cms-plugins/Wordpress Feeds================<?php bloginfo('rss2_url'); ?> - RSS 2.0 format<?php bloginfo('rss_url'); ?> - RSS 0.92 format<?php bloginfo('rdf_url'); ?> - RDF/RSS 1.0 format<?php bloginfo('atom_url'); ?> - Atom format给atom feed 添加图标function mwp_atomImage() { echo " <icon>http://digwp.com/images/favicon.ico</icon> <logo>http://digwp.com/images/feed-icon.png</logo> "; } add_action('atom_head', 'mwp_atomImage');给你的wordpress理发===================去掉在wp-head的版本号<?php remove_action('wp_head', 'wp_generator'); ?>其它remove_action('wp_head', 'rsd_link');remove_action('wp_head', 'wp_generator');remove_action('wp_head', 'feed_links', 2);remove_action('wp_head', 'index_rel_link');remove_action('wp_head', 'wlwmanifest_link');remove_action('wp_head', 'feed_links_extra', 3);remove_action('wp_head', 'start_post_rel_link', 10, 0 );remove_action('wp_head', 'parent_post_rel_link', 10, 0);remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);在feeds里添加自定义内容=======================function insertContent($content) { $content = $content . '<p>Place your custom content here!</p>'; return $content; } add_filter('the_excerpt_rss', 'insertContent'); add_filter('the_content_rss', 'insertContent');评论====<ol> <?php wp_list_comments();?> </ol>p220自定义评论<ul class="commentlist"> <?php wp_list_comments('type=comment&callback=mytheme_comment'); ?> </ul>需要在functions里写自己的mytheme_comment函数 http://codex.wordpress.org/Template_Tags/wp_list_comments调用评论翻页============<?php previous_comments_link();?> <?php ext_comments_link();?>
消除多页重复评论插件:: SEO for Paged Comments添加自己的thread comment功能p226分割评论和trackback===================<h3>Comments</h3> <ol class="comments"> <?php wp_list_comments('type=comment'); ?> </ol> <h3>Pingbacks/Trackbacks</h3> <ol class="pingbacks-trackbacks"> <?php wp_list_comments('type=pings'); ?> </ol>更清新的Pingback和Trackbacks输出================================function cleanPings($comment, $args, $depth) { $GLOBALS['comment'] = $comment; echo '<li>'.comment_author_link().'</li>'; }为wp_list_comments 添加callback--------------------------------<?php wp_list_comments('type=pings&callback=cleanPings'); ?>只在pingsback/trackbacks有内容时显示-------------------------------------p232local comments number---------------------<?php $commentcount = 1 // number of first comment ?> <p class="comment-count"><a href="#comment-<?php comment_ID(); ?>">#<?php echo $commentcount++; ?></a></p>
或者<a href="<?php the_permalink(); ?>#comment-<?php comment_ID(); ?>" id="comment-<?php comment_ID(); ?>" title="Permalink for comment #<?php echo $comment_count; ?>">Comment #<?php echo $comment_count; ?></a>
只统计评论数目--------------function countComments($count) { global $wp_query; return count($wp_query->comments_by_type['comment']); } add_filter('get_comments_number', 'countComments', 0);自定义评论的风格---------------#. 奇数和偶数行#. 作者和成员<?php foreach ($comments as $comment) : ?> <div<?php if ($comment->user_id == $post->post_author) { echo ' class="comment-author"'; } ?>> <p><strong><?php comment_author_link(); ?></strong></p> <?php comment_text(); ?> </div> <?php endforeach; ?>p242gravatar--------添加在comments loop里:<?php if(function_exists('get_avatar')) { echo get_avatar($comment, $size = '50', $default = 'http://domain.tld/default.png'); } ?>在文章里添加gravatar<?php $author_email = get_the_author_email(); echo get_avatar($author_email,'96'); ?>
twitter avatar--------------<?php twitter('50','http://domain.tld/default.png','#ffffff','twitavatars',1,'G');?>改变评论排序,让最新的在最前----------------------------<?php $comments = array_reverse($comments, true); ?> <?php foreach ($comments as $comment) : ?> <?php comment_author_link(); ?> <?php comment_text() ?> <?php endforeach; ?>
防治垃圾评论------------ http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/ 插件:: Akismet Peter's Custom Anti-Spam reCAPTCHA Plugin WP-HashCash Simple Trackback ValidationSEO---p261更安全的WP-----------p299改变数据库前缀 p314php压缩 http://perishablepress.com/press/2007/03/26/fast-effective-php-compression/反盗链<IfModule mod_rewrite.c>RewriteEngine onRewriteCond %{HTTP_REFERER} !^$RewriteCond %{REQUEST_FILENAME} -fRewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$ [NC]RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?domain\. [NC]RewriteRule \.(gif|jpe?g?|png)$ - [F,NC,L]</ifModule>http://perishablepress.com/press/2007/11/21/creating-the-ultimate-htaccess-anti-hotlinking-strategy/Nonus Tricks=============添加theme options p346自定义主题目录=============<?php register_theme_directory('alt-themes'); ?>alt-theme 相对于wp-content 路径Multisite=========p378Custom Taxonomies=================p383Custom Menus============function register_menus() { register_nav_menus( array( 'primary-menu' => __('Primary Menu'), 'secondary-menu' => __('Secondary Menu'), 'tertiary-menu' => __('Tertiary Menu') ) ); } add_action('init', 'register_menus'); <?php wp_nav_menu( array( 'theme_location' => 'primary-menu' ) ); ?>Custom Post Types=================p387ShortLink==========<?php the_shortlink('shortlink', null, '<p>', '</p>'); ?>wp3.0 添加了新的comment_form函数================================<?php comment_form();?>
wp3.1的新功能==============custom post format-------------------改变post的样式已适应内容,10种post_format:: • Standard – A regular blog post (no format) • Aside – Small blurbs, random thoughts, etc. • Chat – Dialogue from instant messaging and chat • Gallery – Groups of images or other media files • Image – Any image • Link – Cool links to awesome resources • Quote – Any quote • Status – Updates to 3rd-party services, like Twitter • Video – Any video, screencast, slideshow, etc. • Audio – Any audio clip, song, or podcast只支持 custom_post formatsadd_theme_support('post-formats',array('aside','chat','gallery','image','link','quote','status','video','audio'));使用post_formatspost format tags:: set_post_format() get_post_format() get_post_format_link() get_post_format_string() has_post_format()post format classes:: .format-aside .format-gallery .format-link .format-image .format-quote .format-status .format-video .format-audio .format-chatAdvanced Custom Field Queries=============================p397 http://codex.wordpress.org/Function_Reference/WP_Query#Custom_Field_ParametersAdvanced Taxonomy Queries==========================p399-400tax_query examples:: http://ottopress.com/2010/wordpress-3-1-advanced-taxonomy-queries/User Queries=============get_users 函数::<?php // display a list of subscriber emails $blogusers = get_users('blog_id=1&orderby=nicename&role=subscriber'); echo '<ul>'; foreach ($blogusers as $user) { echo '<li>' . $user->user_email . '</li>'; } echo '</ul>'; ?>docs:: http://codex.wordpress.org/Function_Reference/get_usersWP 3.3 的关键特性=================#. wp_editor API#. jquery upgrade#. is_main_query()#. post-format (收起)2012-02-12 21:18:25 1人收藏 回应
第一个在"Digging into WordPress"的论坛里发言

