此代碼將顯示來自某個類別的最新帖子。該帖子只會顯示 摘錄,旁邊是用戶頭像。在wordpress中使用get_avatar
注意:在使用IM的插件根據WordPress的所謂local avatar
//display newest post//
<?php
global $post;
$args = array('numberposts' => 1, 'category' => 1);
$myposts = get_posts($args);
foreach($myposts as $post):setup_postdata($post); ?>
//gets user avatar and excerpt//
<?php echo get_avatar(get_the_author_meta('user_email')); ?>
<a href="<?php the_permalink(); ?>"><?php echo get_excerpt(100); ?>... </a>
<?php endforeach; ?>
,如果我想顯示用戶頭像,我應該包括循環<?php echo get_avatar($id_or_email, $size = '50'); ?>
這個代碼僅顯示默認的頭像裏面以下。
所以我用這個,它是從默認的wordpress模板 <?php echo get_avatar(get_the_author_meta('user_email')); ?>
這兩個本地上傳的頭像和gravatar作品。
我只是想澄清爲什麼後者的作品,而不是在wordpress codex中發現的。