我正在使用一个主题,它将特色图像显示为帖子导航元素中的背景图像(单个帖子上的下一个和上一个链接)。但我想删除这些背景图像。
下面是模板标记中的实际代码。php文件。
function shoreditch_post_nav_background() {
if ( ! is_single() ) {
return;
}
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, \'\', true );
$next = get_adjacent_post( false, \'\', false );
$css = \'\';
if ( is_attachment() && \'attachment\' == $previous->post_type ) {
return;
}
if ( $previous && has_post_thumbnail( $previous->ID ) ) {
$prevthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $previous->ID ), \'post-thumbnail\' );
$css .= \'
.post-navigation .nav-previous { background-image: url(\' . esc_url( $prevthumb[0] ) . \'); text-shadow: 0 0 0.15em rgba(0, 0, 0, 0.5); }
.post-navigation .nav-previous .post-title,
.post-navigation .nav-previous a:focus .post-title,
.post-navigation .nav-previous a:hover .post-title { color: #fff; }
.post-navigation .nav-previous .meta-nav { color: rgba(255, 255, 255, 0.75); }
.post-navigation .nav-previous a { background-color: rgba(0, 0, 0, 0.2); border: 0; }
.post-navigation .nav-previous a:focus,
.post-navigation .nav-previous a:hover { background-color: rgba(0, 0, 0, 0.4); }
\';
}
if ( $next && has_post_thumbnail( $next->ID ) ) {
$nextthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $next->ID ), \'post-thumbnail\' );
$css .= \'
.post-navigation .nav-next { background-image: url(\' . esc_url( $nextthumb[0] ) . \'); text-shadow: 0 0 0.15em rgba(0, 0, 0, 0.5); }
.post-navigation .nav-next .post-title,
.post-navigation .nav-next a:focus .post-title,
.post-navigation .nav-next a:hover .post-title { color: #fff; }
.post-navigation .nav-next .meta-nav { color: rgba(255, 255, 255, 0.75); }
.post-navigation .nav-next a { background-color: rgba(0, 0, 0, 0.2); border: 0; }
.post-navigation .nav-next a:focus,
.post-navigation .nav-next a:hover { background-color: rgba(0, 0, 0, 0.4); }
\';
}
wp_add_inline_style( \'shoreditch-style\', $css );
}
add_action( \'wp_enqueue_scripts\', \'shoreditch_post_nav_background\' );
如何在使用子主题函数时删除这些背景图像。php文件,而不修改父主题中的实际文件?