WordPress默认的头像是读取gravatar.com上的图片的,对于国内用户来说会使网页打开速度变慢。所以我决定删除掉这块功能。修改get_avatar函数,在wp-includes/pluggable.php内。修改后的函数如下:代码如下: ?php if ...
?php /** * 获取文章的评论人数 *$postid:文章id *$which:返回类型(0或1)为0时返回评论人数,为1时返回评论条数 */ function count_comments($postid=0,$which=0) { $comments = get_comments('status=approvetype ...
is_single()判断是否是具体文章的页面is_single('2')判断是否是具体文章(id=2)的页面is_single('Beef Stew')判断是否是具体文章(标题判断)的页面is_single('beef-stew')判断是否是具体文章(slug判断)的页面com ...
!–smilies– ?php function wp_smilies() { global $wpsmiliestrans; if (!get_option('use_smilies') or ( empty($wpsmiliestrans))) return; $smilies = array_unique($wpsmiliestrans); $link = ''; foreach ($s ...
1、日志总数:?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts-publish;?2、草稿数目:?php $count_posts = wp_count_posts(); echo $draft_posts = $count_posts-draft; ?3、评论总数 ...
?php global $wpdb; $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved,comment_author_email, comment_type,comment_aut ...
?php global $wpdb; $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(co ...
category=4 这里定义分类的IDnumberposts=10 这里定义要调取的条数 ?php $posts = get_posts( "category=4numberposts=10" ); ? ?php if( $posts ) : ? ul?php foreach( $posts as $post ) : setup_postdata( $post ...
在文章页显示相关文章 ?php $tags = wp_get_post_tags($post-ID); if ($tags) { $first_tag = $tags-term_id; $args = array( 'tag__in' = array($first_tag), 'post__not_in' = array($post-ID), 'showposts' = 10, ...
下面是我之前在一个Wordpress主题中代到的最新留言代码,具体也记不得是哪个主题了。该代码直接调用数据库显示一份最新留言。其中 LIMIT 10限制留言显示数量。绿色部份则是每条留言的输出样式。 ?php global $wpdb; ...
?php $rand_posts = get_posts(‘numberposts=10orderby=rand’); foreach( $rand_posts as $post ) : ? !–下面是你想自定义的Loop– lia href=”?php the_permalink(); ?”?php the_title(); ?/a/li ?php endforea ...
WordPress最新文章的调用可以使用一行很简单的模板标签wp_get_archvies来实现. 代码如下:?php get_archives(‘postbypost’, 10); ? (显示10篇最新更新文章)或者?php wp_get_archives(‘type=postbypostlimit=20for ...
/%postname%/ 显示博客的自定义永久链接?php the_search_query(); ? 搜索表单的值?php _e(‘Message’); ? 打印输出信息?php wp_register(); ? 显示注册链接?php wp_loginout(); ? 显示登入/登出链接!–next page– ...
?php the_content(); ? 日志内容?php if(have_posts()) : ? 确认是否有日志?php while(have_posts()) : the_post(); ? 如果有,则显示全部日志?php endwhile; ? 结束PHP函数”while”?php endif; ? 结束PHP函数”if ...
注: 也就是位于head和/head之间的PHP代码?php bloginfo(‘name’); ? 网站标题?php wp_title(); ? 日志或页面标题?php bloginfo(‘stylesheet_url’); ? WordPress主题样式表文件style.css的相对地址?php bloginfo( ...