向插件输出添加包装器
if ( $rposts->have_posts() ) {
$html = \'<div class="pl_recent_posts">\';
$html .= \'<h3>Recent Posts</h3><ul class="recent-posts">\';
while( $rposts->have_posts() ) {
$rposts->the_post();
$html .= sprintf(
\'<li><a href="%s" title="%s">%s</a></li>\',
get_permalink($rposts->post->ID),
get_the_title(),
get_the_title()
);
}
$html .= \'</ul>\';
$html .= \'</div>\';
}
创建自定义CSS文件
.pl_recent_posts:not(:first-of-type) h3 {
display: none;
}
并将CSS文件排队
function pl_recent_posts_styles() {
wp_enqueue_style( \'pl_recent_posts_style\', plugins_url(\'stylesheet.css\', __FILE__) );
}
add_action( \'wp_enqueue_scripts\', \'pl_recent_posts_styles\' );
这不会将其从DOM中完全删除,但会将其从视图中隐藏