You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何去除WordPress侧边栏近期文章链接的项目符号?

Hey there! Let's get rid of those default bullets on your sidebar's recent posts—super easy to fix with a few different approaches, depending on how comfortable you are with code:

方法1:用CSS(最简单、无风险的方式)

Most WordPress themes add a specific CSS class to the Recent Posts widget, so we can target that to remove the bullets:

  • Head to your WordPress dashboard, go to Appearance > Customize > Additional CSS
  • Paste this code snippet:
/* Remove bullets from sidebar recent posts */
.widget_recent_entries ul {
    list-style: none;
    padding-left: 0; /* Optional: Removes default left padding for cleaner alignment */
}
  • Click Publish to save changes, then refresh your site's front-end to see the bullets disappear.

If the .widget_recent_entries class doesn't work for your theme, right-click on a recent post in the sidebar and select "Inspect" (using your browser's dev tools) to find the correct parent container class for the list, then replace that in the CSS above.

方法2:修改小工具模板(适合懂点代码的用户)

If you want more control over the markup, you can edit the Recent Posts widget template—just make sure to use a child theme so your changes don't get wiped when the parent theme updates:

  1. Create and activate a child theme if you haven't already
  2. Locate the recent posts widget file in your parent theme (usually named recent-posts.php, widget-recent-entries.php, or inside a widgets folder)
  3. Copy that file into your child theme's corresponding folder (create a widgets folder if needed)
  4. Open the copied file and look for the <ul> and <li> tags. Replace the list structure with divs to eliminate bullets entirely. For example:
    Original code might look like:
<ul>
    <?php while ( $recent_posts->have_posts() ) : $recent_posts->the_post(); ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
</ul>

Change it to:

<div class="recent-posts-container">
    <?php while ( $recent_posts->have_posts() ) : $recent_posts->the_post(); ?>
        <div class="recent-post-item"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
    <?php endwhile; ?>
</div>
  1. Save the file, refresh your site, and the bullets will be gone. You can also add custom styles to .recent-post-item in your CSS later if you want.
方法3:使用自定义HTML小工具(无代码替代方案)

If your theme allows PHP in Custom HTML widgets, you can manually generate a bullet-free recent posts list:

  1. Go to Appearance > Widgets in your dashboard, drag the Custom HTML widget into your sidebar
  2. Switch to the "Text" tab (not Visual), then paste this code:
<?php
// Get 5 recent published posts (adjust numberposts to change count)
$recent_posts = wp_get_recent_posts(array(
    'numberposts' => 5,
    'post_status' => 'publish'
));
foreach($recent_posts as $post) : ?>
    <div class="sidebar-recent-post"><a href="<?php echo get_permalink($post['ID']) ?>"><?php echo $post['post_title'] ?></a></div>
<?php endforeach; wp_reset_query(); ?>
  1. Save the widget, and check your sidebar—no bullets! Note: Some themes block PHP in Custom HTML widgets, so if this doesn't work, stick with the CSS method.

内容的提问来源于stack exchange,提问作者melvinrajiv

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:35:12