WordPress 4.9.4站点页脚小工具居中设置问题求助
Hey there! Let's fix that footer widget alignment issue you're having. The reason your CSS didn't work when adding it directly to footer.php is because you placed raw CSS code outside of a <style> tag—browsers can't interpret that as styling. Here are the proper, reliable ways to get your footer widgets centered:
1. Use WordPress Customizer's Additional CSS (Recommended)
This is the safest method since it won't get overwritten when you update your theme:
- Go to your WordPress Dashboard → Appearance → Customize
- Look for the Additional CSS section (usually at the bottom of the menu)
- Paste this code and hit "Publish":
/* Center footer sidebar container */ .footer-sidebar { text-align: center; } /* If individual widget content is still left-aligned, add this too */ .footer-sidebar .widget { text-align: center; }
If the original theme styles are overriding this, add !important temporarily to test (though it's better to use more specific selectors if possible):
.footer-sidebar { text-align: center !important; }
2. Edit the Theme's style.css File
If you prefer editing the theme files directly (note: use a child theme if you don't want changes lost on theme updates):
- Access your site's files via FTP or cPanel File Manager
- Navigate to
wp-content/themes/busiprof/style.css - Search for the
.footer-sidebarselector (or related classes like.footer-widgets) - Change
text-align: left;totext-align: center; - Save the file and clear your browser cache to see the changes
3. Fix Your Original footer.php Approach (Not Recommended)
If you really want to add the CSS to footer.php, you need to wrap it in a <style> tag like this:
<?php $current_options = wp_parse_args( get_option( 'busiprof_theme_options', array() ), theme_setup_data() ); ?> <!-- Footer Section --> <style> .footer-sidebar { text-align: center; } </style> <footer class="footer-sidebar"> <!-- Footer Widgets -->
But again, this is less maintainable than the first two methods.
Quick Troubleshooting Tip
After making changes, clear your browser's cache (press Ctrl+F5 or Cmd+Shift+R)—sometimes old cached styles prevent you from seeing updates immediately.
内容的提问来源于stack exchange,提问作者Caracks

