我需要在帖子信息位置显示一个头像,我已经为其编写了代码,但我只想在主页上的最新帖子上显示头像,而不是在特定帖子上显示头像,因为当发布新帖子id时,这会发生变化。
找不到处理此问题的条件标记。
我在一个自定义函数中使用代码,并在子主题中使用genesis\\u挂钩。
function latest_post_author_avatars() {
if (is_single() || is_home() ) {
echo get_avatar(get_the_author_id(), 40);
}
}
add_action(\'genesis_after_post_title\', \'latest_post_author_avatars\');
//这是最终可行的解决方案。谢谢你们俩。function latest_post_author_avatars() {
global $wp_query;
if (is_single() || is_home() && 0 === $wp_query->current_post) {
echo get_avatar(get_the_author_id(), 40);
}
}
add_action(\'genesis_after_post_title\', \'latest_post_author_avatars\');