gpt4 book ai didi

php - 在wordpress上将标题与缩略图分开

转载 作者:行者123 更新时间:2023-11-28 08:26:32 25 4
gpt4 key购买 nike

我正在做一个 wordpress 主题,我正在尝试在侧边栏上最近发布的帖子的缩略图和帖子标题之间创建一些边距。我尝试了一切,但就是行不通。有什么建议吗?

<?php $recent_posts = wp_get_recent_posts();
foreach( $recent_posts as $recent ){
if($recent['post_status']=="publish"){
if ( has_post_thumbnail($recent["ID"])) {
echo '<li style=" list-style: none; ">
<a class="post-title" href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' . get_the_post_thumbnail($recent["ID"], 'thumbnail').$recent["post_title"].'</a></li> ';
}else{
echo '<li style=" list-style: none; ">
<a class="post-title" href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' . $recent["post_title"].'</a></li> ';
}
}
}
?>

最佳答案

您是否尝试过在它们之间插入一个分隔线?

get_the_post_thumbnail($recent["ID"], 'thumbnail') . '<br />' . $recent["post_title"].'

将此添加到 CSS 文件中:

img.attachment-thumbnail { margin:10px; }

关于php - 在wordpress上将标题与缩略图分开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28507370/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com