在 style.css 里限制PC端的文章特色图片大小
/* twentytwentyfive 仅桌面:单篇文章「文章特色图片」最高 500px,整图可见(不裁切) */
@media (min-width: 782px) {
body.single-post .wp-block-post-featured-image {
max-height: 500px;
aspect-ratio: unset !important; /* 覆盖 figure 内联 aspect-ratio,避免宽屏仍按 16:9 拉高 */
display: flex;
justify-content: center;
align-items: center; /* 可选:在限高区域内垂直也居中 */
}
body.single-post .wp-block-post-featured-image :where(img) {
max-height: 500px;
width: auto !important; /* 配合自然比例;仍可被 max-width 约束 */
max-width: 100%;
height: auto !important; /* 覆盖内联 height:100% */
object-fit: contain !important; /* 与编辑器「适应」一致;整图显示 */
vertical-align: bottom;
}
}
在 functions.php 里为单篇文章页脚添加“编辑文章”简码
// 在单篇文章页脚添加“编辑文章”简码[edit_post_link]
function edit_post_link_shortcode() {
// 只有单篇文章/页面,且用户有编辑权限时才输出
if ( is_singular() && current_user_can( 'edit_post', get_the_ID() ) ) {
$edit_link = get_edit_post_link( get_the_ID() );
if ( $edit_link ) {
return '| <a href="' . esc_url( $edit_link ) . '" target="_blank">编辑文章</a>';
}
}
return ''; // 不满足条件时不显示任何内容
}
add_shortcode( 'edit_post_link', 'edit_post_link_shortcode' );
发表回复
要发表评论,您必须先登录。