
最近在使用Google丰富网页摘要测试工具的时候,发现对于默认Wordpress博客,总会有三条错误信息出现,今天我就介绍一下,如何通过修改Wordpress模版文件来修复这些错误信息的方法。
错误信息内容分别是:
Warning: Missing required field “entry-title”.
Warning: Missing required field “updated”.
Warning: Missing required hCard “author”.
对于entry-title的错误信息修改方法是:
打开single.php文件,找到类似<h1><?php the_title(); ?></h1>一行,将其修改为<h......

调用 WordPress 置顶文章列表:
在需要调用 WordPress 置顶文章的地方直接添加以下代码即可:
<ul>
<?php
$sticky = get_option('sticky_posts');
rsort( $sticky );
$sticky = array_slice( $sticky, 0, 5);
query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) );
if (have_posts()) :
while (have_posts()) : the_post();
?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark&quo......

将以下代码贴入主题的function.php文件:
//缩略图获取
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 140, 98 ,true );//设置缩略图的尺寸
function dm_the_thumbnail() {
global $post;
// 判断该文章是否设置的缩略图,如果有则直接显示
if ( has_post_thumbnail() ) {
echo '<a href="'.get_permalink().'">';
the_post_thumbnail();
echo '</a>';
} else { //如果文章没有设置缩略图,则查找文章内是否包含图片
$content = $post->post_conte......