Skip to content
WordPress

Showing Widgets Only on Specific Pages in WordPress

WordPress widget visibility rules target each widget to the exact pages and users where it adds value. This guide covers Jetpack rules, CSS classes, template conditionals, user roles, and WooCommerce.

Showing Widgets Only on Specific Pages in WordPress

A contact form widget shows on every page including the checkout page where it is irrelevant. A promotional announcement widget appears on article pages where it disrupts reading flow. Or a sidebar widget is only needed on desktop — mobile visitors see it in a jarring position below the main content. WordPress widget visibility controls allow targeting each widget to the specific pages, devices, user states, and post types where it genuinely improves the user experience. This fits into the wider topic we cover in our Complete Guide to WordPress How.

WordPress Widget Visibility — Jetpack vs Plugin Approaches

WordPress widget visibility rules are not built into WordPress core — they require either the Jetpack plugin’s Widget Visibility module or a dedicated plugin. Without one of these, every widget in a sidebar appears on every page where that sidebar is rendered, with no per-widget targeting.

Jetpack’s Widget Visibility module (included in Jetpack, available in the free plan) adds a “Visibility” section to each classic widget in the Widgets admin. Click “Visibility” on any widget → click “Show” to add rules → a dropdown pair appears: “Page is / is not” and “Front Page / Blog / Archive / Single Post / etc.” — build rule sets that define exactly when the widget shows. Multiple rules are combined with “all” (AND) or “any” (OR) logic. Example: show a widget only on single posts that have the “featured” tag → Rule 1: “Page is Single Post” AND Rule 2: “Tag is featured.” The widget appears nowhere else on the site. This targeting without any custom code is the core value of WordPress widget visibility rules and covers the majority of use cases for content-targeting widgets.

The Widget Options plugin (free, 900,000+ installs) is the dedicated alternative to Jetpack’s Widget Visibility for sites that do not use Jetpack. It adds similar show/hide logic with additional targeting options: device visibility (show on desktop only, mobile only, or both), user login state (show only to logged-in users, only to logged-out visitors, or everyone), and post/page-specific targeting. Widget Options installs without a WordPress.com connection — preferable for sites where the Jetpack connection overhead is not wanted for a single visibility feature. Install → activate → a Visibility panel appears in each widget’s settings (both in the classic widget editor and the block-based widget editor). Configure rules per widget without any code. According to the WordPress plugin directory, Widget Options is the most installed dedicated WordPress widget visibility plugin, consistently rated above 4.5 stars for reliability and ease of use across WordPress versions since its introduction.

Block Widget Visibility With CSS Classes

Block-based widgets need a different WordPress widget visibility approach compared to classic widgets — block-based widgets use CSS classes combined with theme or plugin CSS rules to show or hide blocks in different contexts.

Add a CSS class for WordPress widget visibility: in the Widgets block editor, click the widget block → Block settings panel → Advanced → Additional CSS class(es) → add “hide-on-mobile” (or any class name). Then add CSS to the child theme’s style.css or the Customizer’s Additional CSS:

@media (max-width: 768px) {
    .hide-on-mobile { display: none !important; }
}
.show-on-mobile-only {
    display: none !important;
}
@media (max-width: 768px) {
    .show-on-mobile-only { display: block !important; }
}

This CSS-class approach to WordPress widget visibility handles device-based targeting cleanly without any plugin — mobile visitors see only mobile-appropriate widgets, desktop visitors see the full widget set. The limitation: CSS-based hiding sends the widget HTML to the browser even for visitors who do not see it, wasting bandwidth. For widgets with heavy content (image galleries, embedded maps, social feeds) that should never load on mobile, server-side conditional rendering is more efficient than CSS-based hiding. For lightweight text or link widgets, CSS hiding has negligible performance impact and is the simplest implementation path.

Conditional Widget Display in Theme Templates

Advanced WordPress widget visibility that is not covered by plugin rules or CSS classes uses PHP conditional tags directly in theme templates to control whether specific sidebar widget areas render at all for the current request.

Conditionally render an entire sidebar based on page type — showing a different sidebar on single posts versus archive pages:

<?php if (is_single()): ?>
    <?php if (is_active_sidebar('post-sidebar')): ?>
        <aside class="sidebar">
            <?php dynamic_sidebar('post-sidebar'); ?>
        </aside>
    <?php endif; ?>
<?php elseif (is_archive()): ?>
    <?php if (is_active_sidebar('archive-sidebar')): ?>
        <aside class="sidebar">
            <?php dynamic_sidebar('archive-sidebar'); ?>
        </aside>
    <?php endif; ?>
<?php endif; ?>

This template-level WordPress widget visibility goes further than plugin-based rules — it registers separate widget areas for different page types and renders them conditionally, allowing completely different widget configurations per page type without any widgets requiring individual visibility configuration. Each widget area is independently managed in Appearance → Widgets. The tradeoff: this approach requires theme template editing, and each new page type targeting requires a new widget area registration plus a new conditional block in the template. For complex sites with many distinct page types each requiring completely different sidebars, this architecture is more maintainable than a single sidebar with many individually-targeted widgets. Our guide on managing the WordPress sidebar covers the widget area registration that enables multiple sidebar configurations, providing the foundation for this template-level WordPress widget visibility approach.

User Role and Login State Targeting

Some widgets should only appear to specific users — a premium content promotion widget for logged-out visitors, an account management widget for logged-in members, or an admin notification widget visible only to site administrators. WordPress widget visibility based on user state uses either the Widget Options plugin’s login rules or custom PHP conditions.

Widget Options approach: open any widget → Visibility tab → User Role section → select which roles see this widget (Everyone, Logged In Users Only, Logged Out Users Only, or specific roles like Administrator, Editor, Subscriber). The plugin evaluates the current user’s login state and role on each page request and shows or hides the widget accordingly. This is the simplest approach for common user state targeting without custom code.

Custom PHP in the theme template for fine-grained WordPress widget visibility by capability:

<?php if (current_user_can('manage_options')): ?>
    <?php dynamic_sidebar('admin-only-sidebar'); ?>
<?php elseif (is_user_logged_in()): ?>
    <?php dynamic_sidebar('member-sidebar'); ?>
<?php else: ?>
    <?php dynamic_sidebar('guest-sidebar'); ?>
<?php endif; ?>

This renders three completely different widget sets based on user state: admins see admin tools, logged-in members see member-relevant content, and guests see sign-up and conversion widgets. Caching must account for this variation — a page cached for one user state cannot be served to a different user state. Configure the caching plugin to bypass cache for logged-in users or use separate cache variants per login state. WP Rocket’s “Cache for logged-in users” setting creates separate cached versions per user role, ensuring WordPress widget visibility rules based on user state function correctly even when page caching is active. Our guide on WordPress caching covers the cache variation configuration that must align with any user-state-dependent content variation including widget visibility rules that differ between logged-in and logged-out visitors.

WooCommerce Widget Targeting

WordPress widget visibility for WooCommerce sites involves showing product-specific widgets only on shop pages, category widgets only on product archives, and cart-related widgets only when items are in the cart. Jetpack’s Widget Visibility module includes WooCommerce-specific targeting options when WooCommerce is active.

Jetpack Widget Visibility WooCommerce rules: “Page is WooCommerce” targets all WooCommerce pages (shop, product, cart, checkout, account). “Page is Product” targets individual product pages only. “Page is Product Category” targets category archive pages. “Page is Cart / Checkout” targets those specific pages. Using these rules: a “Related Products” widget → Visibility → Show if Page is Product → the widget only renders on product pages, eliminating it from blog posts, the homepage, and other non-product pages. A “Cart Summary” widget → Visibility → Show if Page is Cart or Checkout → the cart widget only appears where it is relevant to the visitor’s purchase flow.

Performance benefits of correctly configured WordPress widget visibility extend beyond UX: widgets that make external API calls (social media feeds, live pricing widgets, inventory displays) generate server-side HTTP requests on every page load. A social feed widget loading on every page across a large blog generates thousands of API requests per day — most of which are on pages where the widget adds no value. Restricting such widgets to only the pages where they serve a purpose (homepage, about page, contact page) using Widget Visibility rules reduces API request volume by 90%+ on content-heavy sites, improving server response times and reducing API rate-limit risk. This performance dimension makes WordPress widget visibility configuration not just a UX optimisation but a technical performance measure that benefits all site visitors through faster page loads. Reviews from Jetpack’s documentation confirm that the Widget Visibility module is one of the most used Jetpack features specifically because it solves the universal WordPress problem of sidebar widgets appearing on every page regardless of relevance — a problem that affects virtually every WordPress site with any sidebar content at all. Our guide on configuring WordPress auto updates covers keeping Jetpack current — the Widget Visibility feature improves with each Jetpack release and targeting options expand over time to cover new WordPress and WooCommerce page types as they are introduced.

Testing WordPress widget visibility rules after configuration requires viewing the site as different user types and on different pages to confirm each rule is working correctly. Use an incognito browser window to test the logged-out visitor experience — widgets set to show only to logged-out users should appear, while widgets for logged-in users should be hidden. Log in with a subscriber-level account (not admin) to test member-facing widgets — admin accounts often bypass restrictions that apply to regular users. Use browser DevTools responsive mode to test mobile visibility rules — switch to a narrow viewport and confirm that mobile-hidden widgets are gone from the layout rather than just visually shifted. For WooCommerce widget rules, add an item to the cart and navigate to the cart page to confirm cart-specific widgets appear, then check a blog post to confirm they do not. A ten-minute systematic test across page types and user states after configuring WordPress widget visibility rules catches misconfigured rules before they affect real visitors rather than being discovered through user feedback days or weeks after deployment.

Migrating widget visibility configurations between WordPress installations — from development to staging to production — requires careful handling since WordPress widget visibility rules are stored in the wp_options table as serialised data. The Widget Options plugin includes an import/export feature that generates a JSON export of all widget configurations including visibility rules — import this JSON on the destination site to replicate the complete widget setup without reconfiguring rules manually. Jetpack Widget Visibility rules are stored in the same widget data serialisation in wp_options — they migrate correctly with any tool that transfers the full database (UpdraftPlus, WP Migrate DB Pro, All-in-One WP Migration) without requiring any additional handling. The only post-migration check needed: verify that any widget rules targeting specific page IDs (showing a widget only on page ID 42) reference the correct page IDs in the destination site — page IDs may differ between development and production, requiring manual rule updates for ID-specific targeting after migration. Page slug or page type targeting (which does not use numeric IDs) migrates correctly without any post-migration updates regardless of the migration method used.

Scheduling WordPress widget visibility for time-limited campaigns — showing a seasonal promotion widget only in December, or an event announcement widget only during a conference week — requires either a plugin with date-based visibility rules or a custom WP-Cron approach. The Scheduled Widgets Premium plugin adds date-range targeting to classic widgets. Widget Options Pro similarly supports date-based display rules. For custom implementation, register a WP-Cron job that activates and deactivates specific widgets on scheduled dates by updating the widget’s active/inactive status in wp_options. The simpler approach for most sites: configure the widget normally with its Jetpack or Widget Options visibility rules → manually activate it at campaign start and deactivate at campaign end. This manual approach requires a calendar reminder for the deactivation date but avoids plugin dependencies for features needed only occasionally. For high-frequency campaigns (weekly promotions, recurring seasonal widgets), the scheduled plugin approach eliminates the manual calendar management overhead that grows unsustainable as campaign frequency increases.

The block editor’s full site editing (FSE) approach used by block themes replaces the classic sidebar widget paradigm entirely — in block themes, the sidebar content is defined in the site editor’s template parts rather than in the Widgets admin. WordPress widget visibility in FSE block themes uses block visibility controls within the Site Editor: select any block in the sidebar template part → Block settings → Visibility (if the theme or a plugin adds this feature). The Blockify theme framework and some FSE-compatible visibility plugins add conditional display controls directly to blocks in the Site Editor. For sites that have migrated to a block theme with full site editing, the classic widget visibility approaches using Jetpack’s Widget Visibility module or Widget Options do not apply to the Site Editor context — only FSE-compatible visibility solutions work in this environment. The WordPress ecosystem is actively developing standardised block visibility controls for the Site Editor context, and future WordPress versions are expected to include more native visibility targeting options that eliminate the need for third-party plugins for basic WordPress widget visibility configuration in block theme environments. Our guide on understanding the WordPress block editor covers the block editing system and full site editing architecture that determines which widget visibility approach is applicable for the specific theme and WordPress version in use.

Nikolas Lamprou

Nikolas Lamprou (MSc; GCFR, SC-200, Security+) has been working with computers professionally since 2009 — starting with web development and e-commerce, and moving into cybersecurity over the years. Based in Greece, he brings over 15 years of real-world IT experience to SolveTechToday, where he writes about Windows fixes, software reviews, security tools, and AI applications. His goal is straightforward: cut through the noise and give readers clear, honest guidance on the tech decisions that matter.

Stay Ahead

Fix your next problem before it starts

Get the week's best Windows fixes, software picks, and security guides delivered straight to your inbox. No noise, just solutions.

Press ESC to close · Try "Windows 11" or "Chrome"