WordPress Tags Widget in PHP
This PHP snippet is designed to display tags for the current WordPress post or page in a widget area (sidebar or footer). Each tag is styled with a custom orange background and a white font. The tags are also clickable links to their respective archive pages.
- Dynamic Display: Automatically fetches and displays tags for the current post or page.
- Custom Styling:
- Orange background (
#f66c2d) - White font (
#ffffff) - Adjustable font size and padding
- Orange background (
- Clickable Links: Tags link directly to their respective archive pages.
- Lightweight: Inline styling ensures no external CSS is required.
-
Add a PHP Widget Plugin
Install a plugin like PHP Code Widget to enable PHP in widget areas. -
Paste the Code
Copy and paste the provided PHP code into a PHP widget in your WordPress sidebar or footer area. -
Save and Test
- Visit a post or page with tags to confirm functionality.
- Tags will be displayed with the custom styles and link to their respective archive pages.
Modify the font-size property in the code to change the size of the tag text.
font-size: 16px; /* Adjust as needed */