作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在做一个 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/
我是一名优秀的程序员,十分优秀!