抱歉,在的参数列表中,我没有看到任何这些参数wp_get_recent_posts
.
$args = array(
\'numberposts\' => 10,
\'offset\' => 0,
\'category\' => 0,
\'orderby\' => \'post_date\',
\'order\' => \'DESC\',
\'include\' => ,
\'exclude\' => ,
\'meta_key\' => ,
\'meta_value\' =>,
\'post_type\' => \'post\',
\'post_status\' => \'draft, publish, future, pending, private\',
\'suppress_filters\' => true );
与您的代码进行比较。
$default_attr = array(
\'src\' => $src,
\'class\' => "attachment-$size",
\'alt\' => trim(strip_tags( $attachment->post_excerpt )),
\'title\' => trim(strip_tags( $attachment->post_title )),
);
$pages = wp_get_recent_posts($default_attr);
这些是正确的参数
get_the_post_thumbnail
...
// straight from the Codex
$default_attr = array(
\'src\' => $src,
\'class\' => "attachment-$size",
\'alt\' => trim(strip_tags( $attachment->post_excerpt )),
\'title\' => trim(strip_tags( $attachment->post_title )),
);
。。。但你没有用它们,这在我看来是个错误。您的呼叫
get_the_post_thumbnail
需要。。。
echo get_the_post_thumbnail($page["ID"],\'\',$default_attr);
。。您不需要将这些参数传递给
wp_get_recent_posts
.
看起来您已经从Codex中复制了默认参数,并试图使用这些未更改的参数。那是行不通的。这些默认参数取决于没有为代码设置的内容。其次,只需传递要更改的参数。例如
// straight from the Codex
$default_attr = array(
\'class\' => "nifty-class", // this is added to other classes. It does not replace them
\'alt\' => "I am soooo alt",
\'title\' => "And I am a title",
);
echo get_the_post_thumbnail($page["ID"],\'\',$default_attr);
如果你通过
src
必须正确,否则图像将无法加载。