Close sidebar
James Osborne
Blog, WordPress Tips

Restricting widgets to selected URLs, pages or posts

Restricting WordPress Widgets

If you don’t have access to your site via FTP, if you prefer not to create your own WordPress templates or you don’t know how to register new widget positions (also known as sidebars) there are other ways to ensure you can easily restrict widgets to particular pages, posts or taxonomies on your site. It can be achieved with the use of some easy to use plugins.

To do so you don’t need to be a developer and you don’t even need to modify any code within your themes.

The below are plugins I’ve used previously which are lightweight, ease to use and work great. There are many other good sidebar plugins out there, but the below work on just about any theme and are regularly updated.

Lightweight Sidebar Manager

I find this plugin super lightweight, easy to use and not too detrimental to the overall admin panel dashboard, with many new plugins these days inserting their own admin bar tab, or top level settings panel – particularly annoying features for plugins which are not accessed frequently.

To create a new sidebar that appears on your homepage using this plugin follow the steps below, with the example displaying the “Right Sidebar” widget on the homepage only:

  1. After installing and activating the plugin access the settings via “Settings > Sidebars”
  2. Click on “Add New”
  3. Give it a suitable “Name”, such as “Homepage Right Sidebar”
  4. Next is the important part, the “Sidebar to Replace” field. You can select “Sidebar Right” widget if your theme features this sidebar.
    Important side note: If you have an existing widget placed in the “Sidebar Right” position that widget will no longer appear on the homepage. It will remain in place for any other URLs, pages or posts, but not for the hompage, which we’ve set in step 5.
  5. Give it a suitable description using the “Description” field, which you can refer to when adding a widget to this position.
  6. For the “Display” field you’ll see different options, allowing for various placement conditions. In our case we want this widget to appear on the homepage only, so choose “Special Pages” and then “Front Page“. If you have your homepage set to show a list of blog posts you can select “Special Pages” and then add a “Display Rule” to display on the homepage only (Special Pages > Front Page)
  7. Next for the “User Roles” tab. You can leave this to the default setting, unless you prefer to restrict the widget for a particular audience.
  8. You’ve just created a new widget position, which will only appear on the homepage (which is dependent on this plugin remaining active). To add content to that position do as you would normally when creating a new widget (Appearance > Widgets”)
  9. Drag and drop a widget such as a “Text” widget into your newly created “Homepage Right Sidebar” position.
  10. Enter some text into the widget and press “Save”
  11. Visit your site and providing everything is setup correctly you’ll notice the text widget appearing on the homepage only.

Custom Sidebars

Custon Sidebars is a popular plugin with over 200k installs, and built by the WPMU DEV team, the same team that create popular plugins such as Hummingbird and Smush.

To create a new widget area with Custom Sidebars follow the steps below:

  1. After installing and activating the plugin navigate to “Appearances > Widgets”
  2. Click on “Create a new sidebar”
  3. Give it a suitable name such as “Homepage only right sidebar”, and a suitable description which you can refer to if needed (suitable for large sites with multiple custom widgets)
  4. Click on the “Create Sidebar” button
  5. You’ll then see the “Homepage only right sidebar” widget area in the main widgets screen
  6. Drag and drop a widget such as a “Text” widget into this newly created widget
  7. Next click on the “Sidebar Location” button
  8. From this screen you’ll see an array of options in the form of dropdowns. You can choose your preferred setup. For this example we want the widget to appear on the homepage only. If our homepage is set to show a list of blog posts then we can select the “For Archives” box, then the “As Sidebar Right..” before then clicking in the box below which appears and setting the condition to “Front Page”
  9. Press the “Save Changes” button
  10. The widget is then set to appear on your homepage only, replacing the widget you selected in step 8.

Bear in mind with this plugin it does alter the appearance of your native “Widgets” panel slight, along with adding a free “Site Health Check” box, which cross promotes one of the developers other plugins.

Despite the above the good thing about this plugin is that you don’t need to leave the “Widgets” tab to get your new widget up and running, and positioned only on the posts or pages you like.

The above are plugins I’ve used for my own projects. Some themes also have their own featured placements, allowing you to assign content in particular areas within their theme.

With WordPress edging towards a blocks based building CMS it could be time for theme and plugin developers implementing more block based features. Further down the line who know how useful widgets will be?

This website may use cookies, web beacons, tracking pixels, and other tracking technologies, including any other media form, media channel, mobile website, or mobile application.