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

请求协助为WordPress网站分页添加当前页指示器

Fixing WordPress Pagination Current Page Styling Not Working

Hey there! Let's troubleshoot why your custom CSS for highlighting the current pagination page isn't taking effect on your site. Here are the most common issues and fixes to try:

1. CSS Specificity Conflict

Your theme’s default styles might be using a more specific selector that overrides your span.page-numbers.current rule. To fix this, boost the specificity of your selector by targeting the parent container of the pagination (most themes use .nav-links or .pagination for this).

Try this code instead:

.nav-links .page-numbers.current {
    background-color: black;
    color: white;
    /* Optional: Add padding/border-radius to make it stand out more */
    padding: 6px 10px;
    border-radius: 3px;
}

If that still doesn’t work, check if the current page element is actually an <a> tag instead of a <span> (some themes keep the current page as a link with the current class). Adjust the selector like this:

.nav-links a.page-numbers.current {
    background-color: black;
    color: white;
    pointer-events: none; /* Prevent clicking the current page link */
}

2. Verify the Element’s Actual Structure

To be 100% sure what selector you need:

  • Right-click on the current pagination number in your browser
  • Select "Inspect" (Chrome/Firefox) to open the developer tools
  • Look at the HTML structure: check if the element is a <span> or <a>, and what parent classes wrap it. Use those to build a more precise selector.

3. Clear Caches

Old cached CSS can prevent your new styles from loading:

  • Browser Cache: Press Ctrl + Shift + R (Windows) or Cmd + Shift + R (Mac) to force a hard refresh.
  • WordPress Cache: If you’re using a caching plugin (like WP Rocket, W3 Total Cache), clear its cache from the plugin settings.

4. Ensure CSS is Added Correctly

Double-check that you’re adding the CSS in the right place:

  • Go to Appearance > Customize > Additional CSS in your WordPress dashboard (this is the safest spot for custom styles)
  • Or, if using a child theme, add it to the style.css file of your child theme (avoid editing the parent theme’s files directly)

Give these steps a try, and your current pagination page should show up with the black background and white text you want!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.09 12:22:33