Title: Widget Context
Author: Kaspars
Published: <strong>2009 年 7 月 16 日</strong>
Last modified: 2024 年 8 月 31 日

---

搜尋外掛

![](https://ps.w.org/widget-context/assets/banner-772x250.png?rev=1919865)

這個外掛**並未在最新的 3 個 WordPress 主要版本上進行測試**。開發者可能不再對這個
外掛進行維護或提供技術支援，並可能會與更新版本的 WordPress 產生使用上的相容性問題。

![](https://ps.w.org/widget-context/assets/icon-256x256.png?rev=1919865)

# Widget Context

 由 [Kaspars](https://profiles.wordpress.org/kasparsd/) 開發

[下載](https://downloads.wordpress.org/plugin/widget-context.1.3.3.zip)

 * [詳細資料](https://tw.wordpress.org/plugins/widget-context/#description)
 * [使用者評論](https://tw.wordpress.org/plugins/widget-context/#reviews)
 *  [安裝方式](https://tw.wordpress.org/plugins/widget-context/#installation)
 * [開發資訊](https://tw.wordpress.org/plugins/widget-context/#developers)

 [技術支援](https://wordpress.org/support/plugin/widget-context/)

## 外掛說明

Use [Widget Context](https://widgetcontext.com) to show and hide widgets on certain
sections of your site — front page, posts, pages, archives, search, etc. Use targeting
by URLs (with wildcard support) for maximum flexibility.

#### Premium Support

Subscribe to our [Premium Support service](https://widgetcontext.com/pro) and get
the PRO 🚀 version of the plugin for free when it’s launched! Your support enables
consistent maintenance and new feature development, and is greatly appreciated.

#### Contribute

 * Suggest code improvements [on GitHub](https://github.com/kasparsd/widget-context-wporg).
 * Report bugs and suggestions on [WordPress.org forums](https://wordpress.org/support/plugin/widget-context).
 * [Help translate](https://translate.wordpress.org/projects/wp-plugins/widget-context)
   to your language.

#### Documentation

Widget visibility can be configured under individual widget settings under “Appearance
Widgets” in your WordPress administration area or through the widget editing interface
in the Customizer.

#### Target by URL

The “Target by URL” is a powerful feature for targeting sections of your website
based on the request URLs. It was inspired by a similar feature in the [Drupal CMS](https://www.drupal.org).

Use relative URLs such as `page/sub-page` instead of absolute URLs `https://example.
com/page/sub-page` because relative URLs are more flexible and make the logic portable
between different domains and server environments.

#### Wildcards

Use the wildcard symbol `*` for matching dynamic parts of the URL. For example:

 * `topic/widgets/*` to match all posts in the widgets category, if your permalink
   structure is set to `/topic/%category%/%postname%`.
 * `page-slug/*` to match all child pages of the page-slug parent page.
 * Use a trailing `?*` to capture URL with all query arguments such as `utm_source`,
   etc. For example, for every `blog/post-slug` also include `blog/post-slug?*`.

#### Exclude by URL

Specify URLs to ignore even if they’re matched by any of the other context rules.
For example, enter `example/sub-page` to hide a widget on this page even when “All
Posts” is selected under “Global Sections”.

## 螢幕擷圖

 * [[
 * Widget Context settings at the bottom of every widget
 * [[
 * Widget Context plugin settings

## 安裝方式

 * Search for **Widget Context** under “Plugins  Add New” in your WordPress dashboard.
 * Widget Context settings will appear automatically under **each widget** under“
   Appearance  Widgets”.
 * Visit “Settings  Widget Context” to configure the available widget visibility
   contexts.

## 使用者評論

![](https://secure.gravatar.com/avatar/579fb532a092421fb3a9b6cf77d622829b88c7995dc161269f79bca5b1744ec7?
s=60&d=retro&r=g)

### 󠀁[Not Working Anymore, Not Supported](https://wordpress.org/support/topic/not-working-anymore-not-supported/)󠁿

 [1badrose](https://profiles.wordpress.org/1badrose/) 2024 年 9 月 5 日 1 則留言

It was an awesome plugin, too bad it isn’t working anymore and you get no support.

![](https://secure.gravatar.com/avatar/9aca140152b9c85d6e2ea7334bcd2adce65ac7bb175e3a8f5ec28492f402ca71?
s=60&d=retro&r=g)

### 󠀁[A MUST for every installation of WordPress](https://wordpress.org/support/topic/a-must-for-every-installation-of-wordpress/)󠁿

 [dimal](https://profiles.wordpress.org/dimalifragis/) 2022 年 1 月 28 日

This is a great plugin, works as expected and you can’t be without it. I would give
a ten star if i could. Thank you for the plugin.

![](https://secure.gravatar.com/avatar/de9eb538cea8ef2d1df0e88c28a95a70424d7240c3a03f07b6a58b3579c7cc1c?
s=60&d=retro&r=g)

### 󠀁[Easy to use](https://wordpress.org/support/topic/simple-to-use-294/)󠁿

 [maxxtrosweden](https://profiles.wordpress.org/maxxtrosweden/) 2021 年 12 月 1 
日

Does what is says. Very good.

![](https://secure.gravatar.com/avatar/260389314f9826dfa08e78a1ccc14bfd971cf04e3725a454b13e8e12523700e8?
s=60&d=retro&r=g)

### 󠀁[Excellent but Not Playing Well With the New Gutenberg Widget](https://wordpress.org/support/topic/excellent-but-not-playing-well-with-the-new-gutenberg-widget/)󠁿

 [JomJalan](https://profiles.wordpress.org/lelaiskandar/) 2021 年 10 月 26 日

This is an excellent plugin for controlling where your widget appears. Unfortunately
it does not work well with the new Gutenberg Widget. For example, when you select
the option for Show Wwidget on Selected, it no longer open a text field to insert
your url. I hope Kaspars release an update soon.

![](https://secure.gravatar.com/avatar/ecd66fa89ae3e128fb6cb5bc801148b6cbcc3315b01e12c4a3525da1b98ee5ac?
s=60&d=retro&r=g)

### 󠀁[it does the job but](https://wordpress.org/support/topic/it-does-the-job-but-3/)󠁿

 [tbaikamine](https://profiles.wordpress.org/tbaikamine/) 2021 年 7 月 16 日

it works. that’s the important thing however it’s a bit complicated to deal with
I wanted to simply include a widget in specific pages but there is no such option
you can only decide based on the post type. it’s surprising that selection based
on page “slug” is not an option ! when it should be the most basic thing to use.

![](https://secure.gravatar.com/avatar/7a33eaec0674299b41c94074434399db048556dc803bdba09b6dce8e27eceac7?
s=60&d=retro&r=g)

### 󠀁[Excelent!!!](https://wordpress.org/support/topic/excelent-1180/)󠁿

 [fernandokerber](https://profiles.wordpress.org/fernandokerber/) 2021 年 6 月 12
日

Excellent plugin! Solved a problem that was breaking my mind. Thanks! I recommend
to everyone

 [ 閱讀全部 96 則使用者評論 ](https://wordpress.org/support/plugin/widget-context/reviews/)

## 參與者及開發者

以下人員參與了開源軟體〈Widget Context〉的開發相關工作。

參與者

 *   [ Kaspars ](https://profiles.wordpress.org/kasparsd/)
 *   [ James Collins ](https://profiles.wordpress.org/jamescollins/)

〈Widget Context〉外掛目前已有 10 個本地化語言版本。 感謝[全部譯者](https://translate.wordpress.org/projects/wp-plugins/widget-context/contributors)
為這個外掛做出的貢獻。

[將〈Widget Context〉外掛本地化為台灣繁體中文版](https://translate.wordpress.org/projects/wp-plugins/widget-context)

### 對開發相關資訊感興趣？

任何人均可[瀏覽程式碼](https://plugins.trac.wordpress.org/browser/widget-context/)、
查看 [SVN 存放庫](https://plugins.svn.wordpress.org/widget-context/)，或透過 [RSS](https://plugins.trac.wordpress.org/log/widget-context/?limit=100&mode=stop_on_copy&format=rss)
訂閱[開發記錄](https://plugins.trac.wordpress.org/log/widget-context/)。

## 變更記錄

#### 1.3.3 (August 31, 2024)

 * Mark as tested with WordPress 6.6 and PHP 8.2, see [#72](https://github.com/kasparsd/widget-context-wporg/pull/72).

#### 1.3.2 (April 27, 2020)

 * Bugfix: Fix the Widget Context settings link in the widget controls after moving
   the settings under the “Appearance” menu for usability (closer to the widget 
   settings).
 * Feature: Add a link to the plugin settings in the plugin admin list, too.

#### 1.3.1 (April 24, 2020)

 * Bugfix: better support for URL rules with query parameters.

#### 1.3.0 (April 23, 2020)

 * Introduce the long-awaited “Exclude by URL” feature to prevent certain URLs from
   showing or hiding a widget when it’s matched by any other visibility rule.
 * Introduce [premium support](https://widgetcontext.com/pro) to help maintain the
   plugin. Subscribe now to get the PRO version of the Widget Context for free when
   it’s launched!

#### 1.2.0 (August 20, 2019)

 * Set PHP 5.6 as the minimum supported version of PHP to match WordPress core.
 * Developer tooling update: introduce PHP autoloading, PHP unit tests with proper
   mocking, linting for JS, switch to Docker inside a Vagrant wrapper for local 
   development environment and update to the latest version of WordPress coding 
   standards (see [#50](https://github.com/kasparsd/widget-context-wporg/pull/50)).

#### 1.1.1 (June 9, 2019)

 * Mark as tested with WordPress 5.2.
 * Add test coverage reporting and remove [Debug Bar](https://wordpress.org/plugins/debug-bar/)
   integration since it wasn’t complete. Refactor plugin structure to support dependency
   integration. See [#47](https://github.com/kasparsd/widget-context-wporg/pull/47).
 * Added local development environment, see [#48](https://github.com/kasparsd/widget-context-wporg/pull/48).

#### 1.1.0 (June 13, 2018)

 * Fix URL matching for URLs with query strings.
 * Introduce unit tests for the URL context.

#### 1.0.7 (June 5, 2018)

 * Mark as tested with WordPress 4.9.6.
 * Use the localisation service provided by [WP.org](https://translate.wordpress.org/projects/wp-plugins/widget-context).
 * Support for Composer.

#### 1.0.6 (January 20, 2018)

 * Fix path to admin scripts and styles, props @tedgeving.
 * Mark as tested with WordPress 4.9.2.

#### 1.0.5 (May 8, 2017)

 * Confirm the plugin works with the latest version of WordPress.
 * Add support for continuous testing via [wp-dev-lib](https://github.com/xwp/wp-dev-lib).

#### 1.0.4 (May 6, 2016)

 * Confirm the plugin works with the latest version of WordPress.
 * Fix the PHP class constructor warning.
 * Move the widget context settings link.
 * Fix the initial context state in the customizer.

#### 1.0.3

 * Include Russian translation (Thanks Flector!).
 * Add textdomain to the remaining strings.
 * Enable debugging if [Debug Bar](https://wordpress.org/plugins/debug-bar/) is 
   available.

#### 1.0.2

 * Load available custom post types and taxonomies right before visibility checks
   to avoid PHP warnings.
 * Run visibility checks only after the main post query has run. Fixes issues with
   WooCommerce.
 * Load our CSS and Javascript files only on widget and customizer admin pages.

#### 1.0.1

 * Fix PHP warning in custom post type and taxonomy module.

#### 1.0

 * Public release of the 1.0 refactoring.

#### 1.0-beta

 * Improved settings page.

#### 1.0-alpha

 * Refactor code to allow custom widget context modules.

#### 0.8.3

 * Fix PHP warning that occurred on PHP 5.2.x.

#### 0.8.2

 * Improved SSL/HTTPS detection.
 * Fix: Ensure that is_active_sidebar() & is_dynamic_sidebar() don’t return true
   when there are no widgets displayed on a page.
 * Two new filters so that other plugins can override widget context display/visibility
   logic.

#### 0.8.1

 * Revert back to changing callback function in `$wp_registered_widgets` for attaching
   widget context setting controls.
 * Fix the word count logic.

#### 0.8

 * Major code rewrite and refactoring to improve performance and usability.
 * Fix bugs with URL targeting and empty lines in the “Target by URL” textarea.

#### 0.7.2

 * Fix PHP warnings/notices. Props to [James Collins](http://om4.com.au/).

#### 0.7.1

 * Confirm that the plugin works with the latest version of WP.

#### 0.7

 * Bug fix: check for active sidebars only after $paged has been set.

#### 0.6

 * Don’t check for used sidebars on each widget load. Allow absolute URLs in the
   URL check.

#### 0.5

 * Added distinction between is_front_page() and is_home(). Remove widgets from 
   wp_get_sidebars_widgets() if they are not being displayed — this way you can 
   check if a particular sidebar is empty.

#### 0.4.5

 * Widget output callback couldn’t determine the widget_id.

#### 0.4.4

 * Fixed widget control parameter transfer for widgets that don’t use the new widget
   api.

#### 0.4.2

 * Initial release on Plugin repository.

## 中繼資料

 *  版本 **1.3.3**
 *  最後更新 **2 年前**
 *  啟用安裝數 **40,000+**
 *  WordPress 版本需求 ** 3.0 或更新版本 **
 *  已測試相容的 WordPress 版本 **6.6.5**
 *  PHP 版本需求 ** 5.6 或更新版本 **
 *  語言
 * [Danish](https://da.wordpress.org/plugins/widget-context/)、[Dutch](https://nl.wordpress.org/plugins/widget-context/)、
   [English (US)](https://wordpress.org/plugins/widget-context/)、[Russian](https://ru.wordpress.org/plugins/widget-context/)、
   [Spanish (Chile)](https://cl.wordpress.org/plugins/widget-context/)、[Spanish (Colombia)](https://es-co.wordpress.org/plugins/widget-context/)、
   [Spanish (Costa Rica)](https://es-cr.wordpress.org/plugins/widget-context/)、
   [Spanish (Ecuador)](https://es-ec.wordpress.org/plugins/widget-context/)、[Spanish (Mexico)](https://es-mx.wordpress.org/plugins/widget-context/)、
   [Spanish (Spain)](https://es.wordpress.org/plugins/widget-context/)、及 [Spanish (Venezuela)](https://ve.wordpress.org/plugins/widget-context/).
 *  [將這個外掛本地化為你的母語版本](https://translate.wordpress.org/projects/wp-plugins/widget-context)
 * 標籤
 * [context](https://tw.wordpress.org/plugins/tags/context/)[logic](https://tw.wordpress.org/plugins/tags/logic/)
   [widget](https://tw.wordpress.org/plugins/tags/widget/)[widget context](https://tw.wordpress.org/plugins/tags/widget-context/)
   [widgets](https://tw.wordpress.org/plugins/tags/widgets/)
 *  [進階檢視](https://tw.wordpress.org/plugins/widget-context/advanced/)

## 評分

 4.5 星，滿分為 5 星

 *  [  79 個 5 星使用者評論     ](https://wordpress.org/support/plugin/widget-context/reviews/?filter=5)
 *  [  6 個 4 星使用者評論     ](https://wordpress.org/support/plugin/widget-context/reviews/?filter=4)
 *  [  2 個 3 星使用者評論     ](https://wordpress.org/support/plugin/widget-context/reviews/?filter=3)
 *  [  1 個 2 星使用者評論     ](https://wordpress.org/support/plugin/widget-context/reviews/?filter=2)
 *  [  8 個 1 星使用者評論     ](https://wordpress.org/support/plugin/widget-context/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/widget-context/reviews/#new-post)

[查看全部使用者評論](https://wordpress.org/support/plugin/widget-context/reviews/)

## 參與者

 *   [ Kaspars ](https://profiles.wordpress.org/kasparsd/)
 *   [ James Collins ](https://profiles.wordpress.org/jamescollins/)

## 技術支援

使用者可在技術支援論壇提出意見反應或使用問題。

 [檢視技術支援論壇](https://wordpress.org/support/plugin/widget-context/)

## 贊助

想要支援這個外掛的發展嗎？

 [ 贊助這個外掛 ](https://widgetcontext.com/pro)